Skip to content
Need an API key for this client? One token for Claude, GPT-6.2, Gemini 4 & DeepSeek V4 — top up via USDT or Alipay

Connect OpenAI Agents SDK to byesu API ​

Run Python's OpenAI Agents SDK (openai-agents) against byesu to build multi-agent handoffs, guardrails, and @function_tool workflows backed by Claude 5.5, GPT-6.2, DeepSeek V4, Gemini 4, or Grok with a single pay-as-you-go API key.

Quick configuration

  • AsyncOpenAI base_url: https://byesu.com/v1
  • Cross-vendor model wrapper: OpenAIChatCompletionsModel (claude-opus-5-5, claude-sonnet-5-5, deepseek-v4-pro, gemini-4-argon, gpt-6.2-sol)
  • OpenAI /v1/responses wrapper: OpenAIResponsesModel (gpt-6.2-sol, gpt-6.2-astra)
  • Disable hosted trace 401s: call set_tracing_disabled(True) (when not providing a separate OpenAI tracing key)

Prerequisites ​

  1. Create an sk-... token in the byesu Console under the default auto group (see Choosing a Group).
  2. Install openai-agents and export your key:
bash
pip install openai-agents
export BYESU_API_KEY="sk-your-byesu-token"

Production Gotcha #1: Disable Default OpenAI Trace Export ​

By default, openai-agents uploads background execution traces to OpenAI's hosted tracing backend (api.openai.com) using OPENAI_API_KEY. If you run exclusively with BYESU_API_KEY (or point OPENAI_API_KEY at a gateway token), the background trace exporter will log repeated 401 Unauthorized warnings even though your agent calls succeed.

Call set_tracing_disabled(True) at startup (or set export OPENAI_AGENTS_DISABLE_TRACING=1 in your environment) whenever you do not supply a separate official OpenAI key for hosted trace ingestion:

python
from agents import set_tracing_disabled

set_tracing_disabled(True)

Option 1: Cross-Vendor Agents & Handoffs (OpenAIChatCompletionsModel) ​

Pair AsyncOpenAI (base_url="https://byesu.com/v1") with OpenAIChatCompletionsModel to run any model on byesu — and even hand off tasks across vendors in a single run:

python
import asyncio
import os
from openai import AsyncOpenAI
from agents import (
    Agent,
    OpenAIChatCompletionsModel,
    Runner,
    function_tool,
    set_tracing_disabled,
)

# Silence background api.openai.com trace exporter 401 warnings
set_tracing_disabled(True)

client = AsyncOpenAI(
    base_url="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    timeout=120.0,
)


@function_tool
def fetch_error_budget(service: str) -> str:
    """Return remaining 30-day SLO error budget for a production service."""
    return f"{service}: 18.4% error budget remaining (p95 latency 210ms)."


sre_specialist = Agent(
    name="SRESpecialist",
    instructions="Analyze SLO telemetry and give a concrete rollout go/no-go decision.",
    model=OpenAIChatCompletionsModel(
        model="claude-opus-5-5",  # also works with "deepseek-v4-pro", "gemini-4-argon", "gpt-6.2-sol"
        openai_client=client,
    ),
    tools=[fetch_error_budget],
)

triage_agent = Agent(
    name="TriageRouter",
    instructions="Route reliability and deployment questions to SRESpecialist.",
    model=OpenAIChatCompletionsModel(
        model="gemini-3.8-flash",
        openai_client=client,
    ),
    handoffs=[sre_specialist],
)


async def main() -> None:
    result = await Runner.run(
        triage_agent,
        "Check checkout-api error budget and tell me if we should freeze Friday deploys.",
    )
    print(result.final_output)


if __name__ == "__main__":
    asyncio.run(main())

Option 2: OpenAI /v1/responses Agents (OpenAIResponsesModel) ​

When running GPT-6.2 models (gpt-6.2-sol, gpt-6.2-astra) that leverage OpenAI's /v1/responses protocol, wrap the same AsyncOpenAI client in OpenAIResponsesModel:

python
import asyncio
import os
from openai import AsyncOpenAI
from agents import Agent, OpenAIResponsesModel, Runner, set_tracing_disabled

set_tracing_disabled(True)

client = AsyncOpenAI(
    base_url="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    timeout=120.0,
)

planner = Agent(
    name="ArchitecturePlanner",
    instructions="Design pragmatic, migration-safe backend schemas.",
    model=OpenAIResponsesModel(
        model="gpt-6.2-sol",
        openai_client=client,
    ),
)


async def main() -> None:
    result = await Runner.run(
        planner,
        "Propose a zero-downtime PostgreSQL partitioning rollout for an append-only audit table.",
    )
    print(result.final_output)


if __name__ == "__main__":
    asyncio.run(main())

(Keep non-OpenAI models such as claude-opus-5-5, deepseek-v4-pro, and gemini-4-argon on OpenAIChatCompletionsModel.)

Production Engineering Notes ​

  • Omit fixed temperature in ModelSettings: Claude 5.5 (2026-10-21 schema) and GPT-6.2 reasoning models reject legacy temperature / top_p overrides with HTTP 400. Leave ModelSettings without temperature (Claude 400 sampling fix, reasoning_effort values).
  • Client timeouts: Pass timeout=120.0 (or higher) to AsyncOpenAI so deep reasoning turns inside multi-step Runner.run loops do not time out prematurely.
  • Token groups & billing: Default auto tokens cover Claude, GPT, Gemini, DeepSeek, and Grok; create separate tokens in Glm (glm-5.3), Kimi (kimi-k3), or media (gpt-image-2, gemini-3.1-flash-image-ultra) when needed. All text/code models bill pay-as-you-go per token with live rates in the byesu Console after sign-in.

Troubleshooting & Benchmarks ​

Got a problem? Contact support or join our group.