-
-
Notifications
You must be signed in to change notification settings - Fork 4
OpenRouter
Rasmus Wulff Jensen edited this page Dec 26, 2025
·
3 revisions
- AgentFactory (
OpenRouterAgentFactory) - AIToolsFactory integration (tools in
AgentOptions.Tools) - EmbeddingFactory (
OpenRouterEmbeddingFactory) - OpenAI-style reasoning settings and
ClientType(ChatClient or ResponsesApi)
dotnet add package AgentFrameworkToolkit.OpenRouter
OpenRouterAgentFactory agentFactory = new("<apiKey>");
OpenRouterAgent agent = agentFactory.CreateAgent(new AgentOptions
{
Model = "openai/gpt-5",
ReasoningEffort = OpenAIReasoningEffort.Low,
Instructions = "You are a nice AI"
});
AgentRunResponse response = await agent.RunAsync("Hello World");
Console.WriteLine(response);OpenRouterEmbeddingFactory embeddingFactory = new("<apiKey>");
IEmbeddingGenerator<string, Embedding<float>> generator = embeddingFactory.GetEmbeddingGenerator("openai/text-embedding-3-small");
Embedding<float> embedding = await generator.GenerateAsync("Hello");-
ApiKey(required) -
Endpoint(optional, defaults tohttps://openrouter.ai/api/v1) NetworkTimeoutDefaultClientTypeAdditionalOpenAIClientOptions
builder.Services.AddOpenRouterAgentFactory("<apiKey>");
builder.Services.AddOpenRouterAgentFactory(new OpenRouterConnection
{
ApiKey = "<apiKey>"
});- See AgentFactories for shared options and middleware.
- See EmbeddingFactories for more examples.
- See AIToolsFactory for tool creation and MCP support.