Skip to content

Python: Add OrcaRouter as a named chat completion service - #14325

Open
kuswardhanietidims-svg wants to merge 1 commit into
microsoft:mainfrom
kuswardhanietidims-svg:add-orcarouter-provider
Open

Python: Add OrcaRouter as a named chat completion service#14325
kuswardhanietidims-svg wants to merge 1 commit into
microsoft:mainfrom
kuswardhanietidims-svg:add-orcarouter-provider

Conversation

@kuswardhanietidims-svg

Copy link
Copy Markdown

Motivation and Context

Semantic Kernel is a model-agnostic SDK that empowers developers to build, orchestrate, and deploy AI agents and multi-agent systems, and one of its headline features is model flexibility — "connect to any LLM." Today the Python samples let you pick a provider by name from Services (OpenAI, Azure OpenAI, Anthropic, Mistral AI, Ollama, NVIDIA NIM, DeepSeek, ...), and each named provider is wired through a settings class with its own environment-variable prefix.

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. Adding orcarouter as a first-class provider means this project's users can use that stack directly, without treating OrcaRouter as an anonymous custom base URL. It also 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.

Description

This PR mirrors the existing DeepSeek entry (Services.DEEPSEEKget_deepseek_chat_completion_service_and_request_settings) in python/samples/concepts/setup/chat_completion_services.py and adds an equivalent named OrcaRouter provider:

  • Services.ORCAROUTER = "orcarouter" in the Services enum.
  • OrcaRouterSettings(KernelBaseSettings) with the ORCAROUTER_ env prefix (ORCAROUTER_API_KEY, ORCAROUTER_CHAT_MODEL_ID).
  • get_orcarouter_chat_completion_service_and_request_settings() which builds an OpenAIChatCompletion backed by an AsyncOpenAI client pointed at https://api.orcarouter.ai/v1, exactly like the DeepSeek wiring.
  • Services.ORCAROUTER listed in the simple_chatbot.py sample's selectable-service comment.

Verified locally:

  • ruff check and ruff format --check pass on both modified files.
  • mypy reports no errors in the new code (the single existing mypy warning is a pre-existing Onnx type issue in chat_completion_services.py, unrelated to this change).
  • L3 live test: with ORCAROUTER_API_KEY set and ORCAROUTER_CHAT_MODEL_ID=orcarouter/free, calling get_chat_completion_service_and_request_settings(Services.ORCAROUTER) and invoking the resulting service returned a successful chat completion.

Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter

Contribution Checklist


I'm an engineer on the OrcaRouter team.

Copilot AI lite review requested due to automatic review settings August 24, 2026 06:17
@kuswardhanietidims-svg
kuswardhanietidims-svg requested a review from a team as a code owner August 24, 2026 06:17

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 as a first-class, selectable chat completion provider in the Python samples, wired through the existing OpenAI-compatible connector pattern.

Changes:

  • Introduces OrcaRouterSettings (ORCAROUTER_ env prefix) and Services.ORCAROUTER in chat_completion_services.py.
  • Adds get_orcarouter_chat_completion_service_and_request_settings() that creates an OpenAIChatCompletion backed by an AsyncOpenAI client targeting https://api.orcarouter.ai/v1.
  • Updates the simple_chatbot.py sample’s provider-selection comment to include Services.ORCAROUTER.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/samples/concepts/setup/chat_completion_services.py Adds OrcaRouter settings, enum entry, service factory mapping, and OrcaRouter OpenAI-compatible service construction.
python/samples/concepts/chat_completion/simple_chatbot.py Lists OrcaRouter as a selectable service in the sample’s comment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 52 to +56
OLLAMA = "ollama"
ONNX = "onnx"
VERTEX_AI = "vertex_ai"
DEEPSEEK = "deepseek"
ORCAROUTER = "orcarouter"

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): 6e40cce2f62b
Model: claude-opus-4.8

Overview

This PR adds Services.ORCAROUTER as a selectable named chat completion service in
the Python concept samples, mirroring the existing DeepSeek entry and routing through
the OpenAI-compatible connector. The change is confined to two files under
python/samples/concepts/ with no library, public-API, or test surface affected. It
is well guarded: api_key/chat_model_id are checked before use so the SecretStr
is never dereferenced when None, the credential is unwrapped once and passed only to
the AsyncOpenAI client under TLS, and a dedicated ORCAROUTER_ env prefix avoids the
OPENAI_* collision the DeepSeek entry has. Residual items are Low-only: the
selectable-service comment was synced in one sample but not the ~13 others, and
ALL_SETTINGS.md was not updated (both consistent with existing repo state).

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

@kuswardhanietidims-svg

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants