Microsoft.Extensions.AI Integration
Opik provides AIFunction tools compatible with
Microsoft.Extensions.AI,
allowing any IChatClient to interact with Opik's observability and prompt management features.
Available Tools
| Method | Tool Name | Description |
|---|---|---|
AsListProjectsTool() |
ListProjects |
Lists projects with optional name filtering. |
AsGetTraceTool() |
GetTrace |
Retrieves a trace by ID with name, times, and tags. |
AsListPromptsTool() |
ListPrompts |
Lists prompts with optional name filtering. |
AsCreateProjectTool() |
CreateProject |
Creates a new project for organizing traces. |
AsCreateTraceTool() |
CreateTrace |
Logs a new trace for an LLM operation. |
AsCreateSpanTool() |
CreateSpan |
Logs a span within a trace for a sub-operation. |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Tool Details
ListProjects
Lists projects with optional name filtering (partial match, case insensitive).
1 | |
GetTrace
Retrieves a trace by its ID, returning name, start/end times, and tags.
ListPrompts
Lists prompts with optional name filtering. Returns prompt metadata including template structure type, tags, and descriptions.
1 | |
CreateProject
Creates a new project for organizing traces and experiments. Accepts a required name and optional description.
CreateTrace
Logs a new trace for an LLM operation. Requires a name. Optionally specify a project name and comma-separated tags. Returns the generated trace ID.
CreateSpan
Logs a span within an existing trace for a sub-operation (e.g., an LLM call). Requires a trace ID and name. Optionally specify project name, model, and provider. Returns the generated span ID.