Microsoft.Extensions.AI Integration
Cross-SDK comparison
See the centralized MEAI documentation for feature matrices and comparisons across all tryAGI SDKs.
The PromptLayer SDK provides AIFunction tool wrappers compatible with Microsoft.Extensions.AI. These tools can be used with any IChatClient to give AI models access to PromptLayer's prompt management, versioning, request tracking, and workflow capabilities.
Installation
1 | |
Available Tools
| Method | Tool Name | Description |
|---|---|---|
AsListPromptsTool() |
ListPromptTemplates |
Lists available prompt templates with pagination and name filtering |
AsGetPromptTool() |
GetPromptTemplate |
Retrieves a specific prompt template by name or ID, with optional version/label |
AsSearchRequestsTool() |
SearchRequestLogs |
Searches tracked LLM request logs with text query |
AsListWorkflowsTool() |
ListWorkflows |
Lists available workflows with version and release label info |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
Tool Details
ListPromptTemplates
Lists available prompt templates in PromptLayer. Optionally filter by name. Returns template IDs, names, versions, and commit messages.
1 | |
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
perPage |
int |
20 |
Maximum number of templates to return per page |
Function parameters (passed by the AI model):
| Parameter | Type | Required | Description |
|---|---|---|---|
page |
int? |
No | Page number (defaults to 1) |
name |
string? |
No | Filter templates by name |
GetPromptTemplate
Retrieves a specific prompt template from PromptLayer by its name or ID. Optionally specify a version number or label. Returns the template content, metadata, and version info.
1 | |
Function parameters (passed by the AI model):
| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string |
Yes | Template name or ID |
version |
int? |
No | Specific version number |
label |
string? |
No | Release label (e.g., "production", "staging") |
SearchRequestLogs
Searches tracked LLM request logs in PromptLayer. Optionally filter by a text query. Returns paginated request log entries including inputs, outputs, and metadata.
1 | |
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
perPage |
int |
20 |
Maximum number of results to return per page |
Function parameters (passed by the AI model):
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string? |
No | Text query to filter request logs |
page |
int? |
No | Page number (defaults to 1) |
ListWorkflows
Lists available workflows in PromptLayer. Returns workflow IDs, names, latest version numbers, and release labels.
1 | |
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
perPage |
int |
20 |
Maximum number of workflows to return per page |
Function parameters (passed by the AI model):
| Parameter | Type | Required | Description |
|---|---|---|---|
page |
int? |
No | Page number (defaults to 1) |
Dependency Injection
You can register the PromptLayer client and tools with Microsoft.Extensions.DependencyInjection:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Selective Tool Registration
You don't need to register all tools. Pick only what your agent needs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |