Custom LLM provider integration examples for OpenAI Agents SDK with Temporal workflows.
Adapted from OpenAI Agents SDK model providers examples
Before running these examples, be sure to review the prerequisites and background on the integration.
Uses built-in LiteLLM support to connect to various model providers.
Start the LiteLLM provider worker:
# Set the required environment variable for your chosen provider
export ANTHROPIC_API_KEY="your_anthropic_api_key" # For Anthropic
uv run openai_agents/model_providers/run_litellm_provider_worker.pyThen run the example in a separate terminal:
uv run openai_agents/model_providers/run_litellm_auto_workflow.pyThe example uses Anthropic Claude by default but can be modified to use other LiteLLM-supported providers.
Find more LiteLLM providers at: https://docs.litellm.ai/docs/providers
Uses OpenRouter as the model provider, so the agent can run on any of the hundreds of models OpenRouter serves through one API key. OpenRouter speaks the OpenAI Chat Completions API, so the stock OpenAIProvider works once it is pointed at OpenRouter's base URL.
Start the OpenRouter worker:
export OPENROUTER_API_KEY="your_openrouter_api_key"
uv run openai_agents/model_providers/run_openrouter_worker.pyThen run the example in a separate terminal:
uv run openai_agents/model_providers/run_openrouter_workflow.pyThe workflow uses openrouter/auto, so OpenRouter picks a model per request; change OPENROUTER_MODEL in workflows/openrouter_workflow.py to pin any OpenRouter model slug. Tools that run inside the Workflow must be async: the Agents SDK runs sync tools in a thread, which the Workflow sandbox does not allow. See the openrouter sample for calling OpenRouter directly from Activities with cost tracking and budgets.
Baseten, Fireworks AI, and Together AI serve open-weight models behind the OpenAI Chat Completions API. One Worker serves all three: it builds a client for each provider whose API key is set, and each Workflow picks a provider through the model name it gives its agent, <provider>/<model>. Workflows on different providers run side by side on the same Worker.
| Provider | API key | Example model name |
|---|---|---|
| Baseten | BASETEN_API_KEY |
baseten/openai/gpt-oss-120b |
| Fireworks AI | FIREWORKS_API_KEY |
fireworks/accounts/fireworks/models/gpt-oss-120b |
| Together AI | TOGETHER_API_KEY |
together/openai/gpt-oss-120b |
Export the keys you have and start the worker:
export TOGETHER_API_KEY="your_together_api_key"
uv run openai_agents/model_providers/run_openai_compatible_worker.pyThen run the example in a separate terminal. Pass --model once per Workflow to start; with no --model, it starts one Workflow per provider whose key is set in that shell:
uv run openai_agents/model_providers/run_openai_compatible_workflow.py --model together/openai/gpt-oss-120bAny model the provider serves works with its prefix. A model name for a provider without a key, or with an unknown prefix, fails its Workflow without retrying. The providers are defined in openai_compatible_providers.py; add another OpenAI-compatible endpoint by appending to PROVIDERS. Tools that run inside the Workflow must be async: the Agents SDK runs sync tools in a thread, which the Workflow sandbox does not allow. The Temporal docs have a page per provider: Baseten, Fireworks AI, and Together AI.
This example demonstrates tool calling using the gpt-oss reasoning model with a local Ollama server. Running this example requires sufficiently powerful hardware (and involves a 14 GB model download. It is adapted from the OpenAI Cookbook example.
Make sure you have Ollama installed:
ollama serveDownload the gpt-oss model:
ollama pull gpt-oss:20bStart the gpt-oss worker:
uv run openai_agents/model_providers/run_gpt_oss_worker.pyThen run the example in a separate terminal:
uv run openai_agents/model_providers/run_gpt_oss_workflow.py- Custom Example Agent - Custom OpenAI client integration
- Custom Example Global - Global default client configuration
- Custom Example Provider - Custom ModelProvider pattern
- LiteLLM Provider - Interactive model/API key input