Skip to content

Python: Add OrcaRouter provider samples - #7900

Closed
nissrin2020ali-ux wants to merge 1 commit into
microsoft:mainfrom
nissrin2020ali-ux:orcarouter-provider-samples
Closed

Python: Add OrcaRouter provider samples#7900
nissrin2020ali-ux wants to merge 1 commit into
microsoft:mainfrom
nissrin2020ali-ux:orcarouter-provider-samples

Conversation

@nissrin2020ali-ux

Copy link
Copy Markdown

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

  • What are the major changes? A new python/samples/02-agents/providers/orcarouter/ folder with two runnable samples, plus a link row in the providers overview README.
  • What is the impact of these changes? Documentation-only sample additions; no runtime code is touched, so there is no API or behavior impact.
  • What do you want reviewers to focus on? Whether the samples match the existing convention for OpenAI-compatible providers in this repo (e.g. providers/ollama/ollama_with_openai_chat_client.py), and the env-var naming.

The samples point the base_url of OpenAIChatCompletionClient / OpenAIChatClient at https://api.orcarouter.ai/v1 and pick a gateway model such as orcarouter/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 --check and --format pass, and type checks report no findings for the new files.

Files added:

  • python/samples/02-agents/providers/orcarouter/README.md
  • python/samples/02-agents/providers/orcarouter/orcarouter_agent_with_openai_chat_client.py
  • python/samples/02-agents/providers/orcarouter/orcarouter_agent_with_responses_client.py

Related Issue

No related issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (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.

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>
Copilot AI balanced review requested due to automatic review settings August 27, 2026 07:18
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Aug 27, 2026
@github-actions github-actions Bot changed the title Add OrcaRouter provider samples Python: Add OrcaRouter provider samples Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"),
Comment on lines +43 to +47
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`)
@moonbox3

Copy link
Copy Markdown
Contributor

This is not something we want to add to our repo at the time. Please feel free to host the sample in your own repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants