Python: Add OrcaRouter provider samples - #7900
Conversation
Add a new orcarouter/ folder under the providers samples that shows how to use the OrcaRouter gateway through the existing OpenAI-compatible clients. OrcaRouter is an OpenAI-compatible AI gateway for models and agents that, like OpenRouter, exposes a provider/model namespace across many models while also combining adaptive routing, failover, observability, guardrails, and agent-tool governance behind the same endpoint. Samples cover both the Chat Completions client and the Responses client, including streaming and tool calling, and the providers overview README now links the new folder. Co-Authored-By: Claude <noreply@anthropic.com>
|
nissrin2020ali-ux please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds OrcaRouter integration samples using Agent Framework’s OpenAI-compatible clients.
Changes:
- Adds Chat Completions and Responses API samples.
- Demonstrates streaming and Chat Completions tool calling.
- Documents OrcaRouter configuration and provider discovery.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
python/samples/02-agents/providers/README.md |
Links the OrcaRouter samples. |
python/samples/02-agents/providers/orcarouter/README.md |
Documents setup and configuration. |
python/samples/02-agents/providers/orcarouter/orcarouter_agent_with_openai_chat_client.py |
Adds a tool-enabled Chat Completions sample. |
python/samples/02-agents/providers/orcarouter/orcarouter_agent_with_responses_client.py |
Adds a Responses API sample. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| def _client() -> OpenAIChatClient: | ||
| """Create an OpenAI Responses client pointed at the OrcaRouter gateway.""" | ||
| return OpenAIChatClient( | ||
| api_key=os.getenv("ORCAROUTER_API_KEY"), |
| def _client() -> OpenAIChatCompletionClient: | ||
| """Create an OpenAI Chat Completion client pointed at the OrcaRouter gateway.""" | ||
| return OpenAIChatCompletionClient( | ||
| api_key=os.getenv("ORCAROUTER_API_KEY"), |
| agent = Agent( | ||
| client=_client(), | ||
| name="Assistant", | ||
| instructions="You are a helpful assistant.", | ||
| ) |
| Set the following environment variables: | ||
|
|
||
| - `ORCAROUTER_API_KEY`: Your OrcaRouter API key | ||
| - `ORCAROUTER_BASE_URL`: The OrcaRouter gateway base URL with `/v1/` suffix (optional, defaults to `https://api.orcarouter.ai/v1`) |
Motivation & Context
Adding OrcaRouter as a first-class provider sample lets Microsoft Agent Framework users drive the OrcaRouter gateway directly through the OpenAI-compatible clients they already use, instead of treating it as an anonymous custom base URL.
OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents. Like OpenRouter, it exposes a provider/model namespace across many models — but it also combines adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance behind the same endpoint. It runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes. Adding
orcarouter/to the provider samples means MAF users can adopt that stack in a single client call.Description & Review Guide
python/samples/02-agents/providers/orcarouter/folder with two runnable samples, plus a link row in the providers overview README.providers/ollama/ollama_with_openai_chat_client.py), and the env-var naming.The samples point the
base_urlofOpenAIChatCompletionClient/OpenAIChatClientathttps://api.orcarouter.ai/v1and pick a gateway model such asorcarouter/fusion. Both cover streaming and tool calling. I verified both samples end-to-end against the gateway — the Chat Completions and the Responses API paths both complete successfully.uv run poe syntax --samples --checkand--formatpass, and type checks report no findings for the new files.Files added:
python/samples/02-agents/providers/orcarouter/README.mdpython/samples/02-agents/providers/orcarouter/orcarouter_agent_with_openai_chat_client.pypython/samples/02-agents/providers/orcarouter/orcarouter_agent_with_responses_client.pyRelated Issue
No related issue.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter
I'm an engineer on the OrcaRouter team.