Tutorials

OpenAI Agents SDK with other models: GPT and DeepSeek on one key

Use the OpenAI Agents SDK with other models: GPT on the Responses API and DeepSeek or other open models on Chat Completions, with one base URL and key.

6 min read · Python · Verified on Sep 26, 2026

The project

You built on the OpenAI Agents SDK, and now you want to try an open model for the everyday work, or compare one with GPT on the same task. Usually that means a second provider, a second key and a second bill.

In this tutorial we build two small weather agents that share one tool. One runs on GPT through the Responses API, the other on an open model through Chat Completions. Both use a single client pointed at SayGM.

At the end one script asks both agents the same question and prints both answers, so you can compare them side by side.

What you'll learn

  • How to point the Agents SDK at SayGM with one AsyncOpenAI client.
  • How to run one agent on the Responses API and another on Chat Completions.
  • How to share one tool between agents on different models.

How it works

The client and the tool are shared. Only the model, and the API it speaks, changes from one agent to the other.

Two agents, one clientThe same question goes to two agents that share the get_weather tool and one AsyncOpenAI client. The GPT agent calls gpt-5.4-nano on the Responses API; the other agent calls the open model deepseek-v4-flash-0731 on Chat Completions. Both requests go through the SayGM gateway on one key.Questionweather in ParisGPT agentResponses APIget_weathershared toolOpen modelagentChatCompletionsSayGM gatewayone clientGPTgpt-5.4-nanoOpen modeldeepseek-v4-flash-0731
Your codeSayGM gatewayModel

What you need

  • Python 3.13.
  • A SayGM key in the SAYGM_API_KEY environment variable.

Setup

Install the OpenAI Agents SDK.

commands.sh
pip install openai-agents==0.22.3

Create an AsyncOpenAI client with the base URL https://api.saygm.com/v1 and make it the SDK's default. Turn tracing off, which would otherwise upload traces to OpenAI.

main.py
import os

from agents import (
    Agent,
    OpenAIChatCompletionsModel,
    Runner,
    function_tool,
    set_default_openai_client,
    set_tracing_disabled,
)
from openai import AsyncOpenAI

client = AsyncOpenAI(base_url="https://api.saygm.com/v1", api_key=os.environ["SAYGM_API_KEY"])
set_default_openai_client(client, use_for_tracing=False)
set_tracing_disabled(disabled=True)

Steps

Define a tool

A decorated function becomes a tool. The SDK builds its schema from the type hints and the docstring. Both agents get this same function, so any difference in their answers comes from the model.

main.py
@function_tool
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"{city}: 18 C and light rain"

Create an agent on GPT

A model name on its own runs on the Responses API. This agent uses gpt-5.4-nano. The SDK's default client is already SayGM's, so the name is all GPT needs.

main.py
gpt_agent = Agent(
    name="Weather assistant on GPT",
    instructions="Answer weather questions. Use the get_weather tool for current conditions.",
    model="gpt-5.4-nano",
    tools=[get_weather],
)

Create an agent on an open model

Wrap the model in OpenAIChatCompletionsModel with the same client. This agent uses deepseek-v4-flash-0731. Open models speak Chat Completions, and the wrapper tells the SDK to use it.

main.py
open_agent = Agent(
    name="Weather assistant on an open model",
    instructions="Answer weather questions. Use the get_weather tool for current conditions.",
    model=OpenAIChatCompletionsModel(model="deepseek-v4-flash-0731", openai_client=client),
    tools=[get_weather],
)

Run both agents

Runner.run_sync runs each agent until it has a final answer.

main.py
question = "What is the weather in Paris? Should I take an umbrella?"

gpt_result = Runner.run_sync(gpt_agent, question)
print(f"GPT: {gpt_result.final_output}")

open_result = Runner.run_sync(open_agent, question)
print(f"Open model: {open_result.final_output}")

Run it

Put the code in main.py in the order above, export your key, and run it. You see one answer from GPT and one from the open model.

commands.sh
python main.py

What you'll see

Both agents called get_weather and told you to take an umbrella. GPT answered in one line; the open model wrote a little more.

Terminal
$ python main.py
GPT: In **Paris**, it’s **18°C** with **light rain** right now—**yes, take an umbrella**.
Open model: Here's the weather update for **Paris**:
🌧️ **Current conditions**: 18°C with **light rain**
**Should you take an umbrella?** **Yes, absolutely!** Since it's currently raining (light rain), you'll definitely want to bring an umbrella if you're heading out. The temperature is cool at 18°C, so you might also want a light jacket or sweater.
From a run of the example on Sep 27, 2026. Long answers are trimmed, and replies change a little from run to run.

Where this stops

Two agents answering one question is a quick comparison. To choose a model for real work, run each on a set of your own tasks and compare quality, speed and cost per task.

This example uses function tools that run in your code, and tracing is off. For a view of runs in production, add your own logging around Runner.run_sync.

Take it further

  • Let the open-model agent hand a question to the GPT agent with the SDK's handoffs.
  • Give both agents the same ten questions and log the answers and token counts side by side.
  • Add a second tool, such as a forecast, and see which model uses it well.
  • Use Runner.run with asyncio.gather to ask both agents at once.

What it costs

You pay per token, from a prepaid balance. SayGM rates are live and typically below list. USD per 1M tokens, uncached input / output. SayGM’s side is the best rate a provider offered, as of 45 minutes ago.

ModelSayGMList priceYou save
GPT-5.4 nanoOpenAI$0.16 / $1.02$0.20 / $1.2518%
DeepSeek-V4-Flash-0731DeepSeek$0.13 / $0.40$0.44 / $1.3269%

The last verified run of this example used 1,049 tokens, which costs less than one centat today’s SayGM rates.

Swap the model

Change the model id in the code to any model that serves the same API, such as a larger model for harder prompts or a confidential model for private data. This tutorial uses:

Every model, its API and its live rate is on the models page.

Next steps

Questions

How do I use a model that is not from OpenAI in the Agents SDK?
Wrap it in OpenAIChatCompletionsModel with the same client. The SDK then calls Chat Completions, which open models on SayGM serve.
Can each agent use a different model?
Yes. Set the model on each Agent. One agent can run on GPT and another on DeepSeek, with the same client, base URL and key.
Why turn tracing off?
The Agents SDK uploads traces to OpenAI by default. The example keeps your SayGM key out of tracing with use_for_tracing=False, and set_tracing_disabled turns the upload off.
Can the Agents SDK run Claude?
Use the Anthropic SDK for Claude, with the same SayGM key. The Claude agent tutorial shows a full tool loop.
How am I billed?
Per token, from a prepaid SayGM balance. The rates on this page are live and typically below list.

Sources

Run it with your own key.

One SayGM key works for every model in this tutorial. Top up once and pay per token.