Python: Add OrcaRouter as a named chat completion service - #14325
Python: Add OrcaRouter as a named chat completion service#14325kuswardhanietidims-svg wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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) andServices.ORCAROUTERinchat_completion_services.py. - Adds
get_orcarouter_chat_completion_service_and_request_settings()that creates anOpenAIChatCompletionbacked by anAsyncOpenAIclient targetinghttps://api.orcarouter.ai/v1. - Updates the
simple_chatbot.pysample’s provider-selection comment to includeServices.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.
| OLLAMA = "ollama" | ||
| ONNX = "onnx" | ||
| VERTEX_AI = "vertex_ai" | ||
| DEEPSEEK = "deepseek" | ||
| ORCAROUTER = "orcarouter" |
There was a problem hiding this comment.
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.
|
@microsoft-github-policy-service agree |
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
orcarouteras 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.DEEPSEEK→get_deepseek_chat_completion_service_and_request_settings) inpython/samples/concepts/setup/chat_completion_services.pyand adds an equivalent namedOrcaRouterprovider:Services.ORCAROUTER = "orcarouter"in theServicesenum.OrcaRouterSettings(KernelBaseSettings)with theORCAROUTER_env prefix (ORCAROUTER_API_KEY,ORCAROUTER_CHAT_MODEL_ID).get_orcarouter_chat_completion_service_and_request_settings()which builds anOpenAIChatCompletionbacked by anAsyncOpenAIclient pointed athttps://api.orcarouter.ai/v1, exactly like the DeepSeek wiring.Services.ORCAROUTERlisted in thesimple_chatbot.pysample's selectable-service comment.Verified locally:
ruff checkandruff format --checkpass on both modified files.mypyreports no errors in the new code (the single existingmypywarning is a pre-existing Onnx type issue inchat_completion_services.py, unrelated to this change).ORCAROUTER_API_KEYset andORCAROUTER_CHAT_MODEL_ID=orcarouter/free, callingget_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.