DEVUP Docs
Back to Dashboard

Integrations

OpenAI Agents SDK

The OpenAI Agents SDK is OpenAI's Python framework for agents that use tools, hand off to each other and stream their answers. Configure it once for DEVUP AI and every agent runs on DEVUP AI models.

Requirements

Install the SDK

bash
pip install openai-agents

Set your API key

The configuration reads the key from DEVUP_API_KEY. Set it in the terminal where you run your agents:

PowerShell

powershell
$env:DEVUP_API_KEY = "YOUR_DEVUP_API_KEY"

Bash

bash
export DEVUP_API_KEY="YOUR_DEVUP_API_KEY"

Connect the SDK to DEVUP AI

Save this as devup_config.py next to your agents. Every example on this page imports RUN_CONFIG from it.

devup_config.py

python
import os

from openai import AsyncOpenAI
from agents import MultiProvider, RunConfig, set_tracing_disabled

client = AsyncOpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
)

# Keep DEVUP AI model IDs such as deepseek-ai/DeepSeek-V4-Pro whole.
provider = MultiProvider(
    openai_client=client,
    openai_prefix_mode="model_id",
    unknown_prefix_mode="model_id",
)
RUN_CONFIG = RunConfig(model_provider=provider)

# The SDK exports traces to OpenAI by default; turn tracing off.
set_tracing_disabled(True)

Settings

SettingValueWhat it does
base_urlhttps://api.devupai.com/v1Sends every request to DEVUP AI.
api_keyDEVUP_API_KEYYour DEVUP AI key, read from the environment.
openai_prefix_mode / unknown_prefix_mode"model_id"Keeps model IDs whole, such as deepseek-ai/DeepSeek-V4-Pro and openai/gpt-5.4-mini.
RunConfig(model_provider=...)RUN_CONFIGPass it to every Runner call.
set_tracing_disabledTrueTurns off the SDK's trace export to OpenAI.

Run your first agent

python
from agents import Agent, Runner

from devup_config import RUN_CONFIG

agent = Agent(
    name="Assistant",
    instructions="You are concise.",
    model="deepseek-ai/DeepSeek-V4-Pro",
)
result = Runner.run_sync(agent, "Reply with exactly: Salam DEVUP", run_config=RUN_CONFIG)
print(result.final_output)

It prints Salam DEVUP.

Stream the answer

Runner.run_streamed returns the answer as it is written:

python
import asyncio

from openai.types.responses import ResponseTextDeltaEvent
from agents import Agent, Runner

from devup_config import RUN_CONFIG


async def main() -> None:
    agent = Agent(
        name="Assistant",
        instructions="You are concise.",
        model="deepseek-ai/DeepSeek-V4-Pro",
    )
    result = Runner.run_streamed(agent, "Count from 1 to 5, separated by commas.", run_config=RUN_CONFIG)
    async for event in result.stream_events():
        if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
            print(event.data.delta, end="", flush=True)
    print()


asyncio.run(main())

Give the agent tools

Decorate a Python function with @function_tool and list it in tools:

python
from agents import Agent, Runner, function_tool

from devup_config import RUN_CONFIG


@function_tool
def get_order_status(order_id: str) -> str:
    """Look up the delivery status of an order by its ID."""
    return f"Order {order_id}: shipped, tracking number DZ-4471"


agent = Agent(
    name="Support",
    instructions="Use get_order_status to answer questions about orders.",
    model="deepseek-ai/DeepSeek-V4-Pro",
    tools=[get_order_status],
)
result = Runner.run_sync(agent, "What is the tracking number for order A-1001?", run_config=RUN_CONFIG)
print(result.final_output)

The agent calls get_order_status and answers with the tracking number DZ-4471.

Get structured output

Set a Pydantic model as output_type:

python
from pydantic import BaseModel
from agents import Agent, Runner

from devup_config import RUN_CONFIG


class City(BaseModel):
    city: str
    country: str


agent = Agent(
    name="Geo",
    instructions="Answer with the capital city and its country.",
    model="deepseek-ai/DeepSeek-V4-Pro",
    output_type=City,
)
result = Runner.run_sync(agent, "What is the capital of Algeria?", run_config=RUN_CONFIG)
print(result.final_output)

It prints city='Algiers' country='Algeria'.

Hand off between agents

The triage agent hands billing questions to the Billing agent. prompt_with_handoff_instructions adds the SDK's recommended instructions for agents that use handoffs:

python
from agents import Agent, Runner
from agents.extensions.handoff_prompt import prompt_with_handoff_instructions

from devup_config import RUN_CONFIG

billing = Agent(
    name="Billing agent",
    handoff_description="Handles billing and payment questions.",
    instructions=prompt_with_handoff_instructions("You answer billing and payment questions."),
    model="deepseek-ai/DeepSeek-V4-Pro",
)
triage = Agent(
    name="Triage agent",
    instructions=prompt_with_handoff_instructions("Hand off billing and payment questions to the Billing agent."),
    model="deepseek-ai/DeepSeek-V4-Pro",
    handoffs=[billing],
)
result = Runner.run_sync(triage, "I was charged twice for my last payment. Who can help?", run_config=RUN_CONFIG)
print(result.last_agent.name)
print(result.final_output)

The first line printed is Billing agent, the agent that answered.

Choose a model

Set model to any DEVUP AI catalog ID. The same tool example on openai/gpt-5.4-mini:

python
from agents import Agent, Runner, function_tool

from devup_config import RUN_CONFIG


@function_tool
def get_order_status(order_id: str) -> str:
    """Look up the delivery status of an order by its ID."""
    return f"Order {order_id}: shipped, tracking number DZ-4471"


agent = Agent(
    name="Support",
    instructions="Use get_order_status to answer questions about orders.",
    model="openai/gpt-5.4-mini",
    tools=[get_order_status],
)
result = Runner.run_sync(agent, "What is the tracking number for order A-1001?", run_config=RUN_CONFIG)
print(result.final_output)

See the Models catalog.

Troubleshooting

  • UserError: Unknown prefix: deepseek-ai:Pass RUN_CONFIG from devup_config.py to every Runner call; its MultiProvider keeps DEVUP AI model IDs whole.
  • The model ID arrives without its openai/ prefix:Keep openai_prefix_mode="model_id" in the MultiProvider, as in devup_config.py.
  • KeyError: 'DEVUP_API_KEY':Set DEVUP_API_KEY in the terminal where you run the agent, as shown above.

FAQ

Does the OpenAI Agents SDK work with DEVUP AI?

Yes. Create an AsyncOpenAI client with base_url https://api.devupai.com/v1 and your DEVUP AI key, wrap it in a MultiProvider with model_id prefix modes, and pass RunConfig(model_provider=...) to every Runner call.

Which models can I use with the Agents SDK?

Any DEVUP AI chat model with tool calling, such as deepseek-ai/DeepSeek-V4-Pro or openai/gpt-5.4-mini. Set it as the model of each agent.

How is Agents SDK usage billed on DEVUP AI?

Every request from your agents is a regular DEVUP AI API call, metered in Algerian Dinar on your account.

Do I need an OpenAI API key?

No. The client uses your DEVUP AI key from DEVUP_API_KEY, and set_tracing_disabled(True) turns off the trace export to OpenAI.

Does streaming work?

Yes. Runner.run_streamed returns the answer as it is written; read the text from the raw response events.

Can agents hand off to each other?

Yes. List the specialist agents in handoffs; the triage agent transfers the conversation and result.last_agent tells you which agent answered.

Related integrations

  • OpenAI SDK: The official OpenAI client libraries on DEVUP AI.
  • Python: Call DEVUP AI from Python with the OpenAI client.
  • Pydantic AI: Type-safe agents with structured output.
  • CrewAI: Teams of agents working on one task.