Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
Joined May 2026
279 Following    408 Followers
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Ever wanted to mix multiple LLM providers within a single agent system? `MultiProvider` automatically routes requests to the right provider based on model name prefixes. 📌 Title: Prefix Routing with MultiProvider 🔗 URL: 🧩 Overview `MultiProvider` routes requests to the appropriate provider based on model name prefixes (e.g., `openai/gpt-4.1`). Setting `openai_prefix_mode="model_id"` treats `openai/...` as a literal model ID, while `unknown_prefix_mode="model_id"` routes unknown prefixes as model IDs too. Enable `openai_use_responses_websocket=True` for WebSocket transport on supported providers. 🛠 How to use it ```python from agents import Agent, MultiProvider, RunConfig, Runner provider = MultiProvider( openai_base_url="", openai_api_key="...", openai_use_responses_websocket=True, openai_prefix_mode="model_id", unknown_prefix_mode="model_id", ) agent = Agent( name="Assistant", instructions="Be concise.", model="openai/gpt-4.1", ) result = await agent, "Hello", run_config=RunConfig(model_provider=provider), ) ``` 🏗 Building it into production ・Assign different provider models to each agent based on cost and latency requirements ・Combine with gateway services like OpenRouter using `openai_prefix_mode="model_id"` to pass prefixed model names through ・Switch providers at runtime via `RunConfig(model_provider=provider)` for A/B testing ・Enable WebSocket for improved streaming performance on supported providers 💡 Use cases 🔀 Routing GPT-4.1 vs GPT-5.5 based on task difficulty 🌐 Unified access to multiple providers through OpenRouter 💰 Hybrid operation mixing high-cost and low-cost models 🧪 Quality comparison testing across different models ⚠️ Watch out By default, `openai/...` aliases to the OpenAI provider, and unknown prefixes raise `UserError`. When using external gateways like OpenRouter, always set both `openai_prefix_mode` and `unknown_prefix_mode` to `"model_id"`. Note that feature support (tool calling, structured output, etc.) varies across providers. ✨ With MultiProvider, build agent systems that freely combine the best models from any provider. #OpenAIAgentSDK# #AIAgent#
Show more