AELDER

Connect OpenAI Agents SDK

Use an explicit Chat Completions model and custom client in the Python OpenAI Agents SDK.

AELDER · SERVICE BASE URL
https://aelder.dev/v1

LOCAL CONFIGURATION

Let my agent set this up

Copy this task to an agent already running on your computer. Enter your API key locally when asked.

SETUP PROMPT
Help me connect OpenAI Agents SDK to AELDER using this guide: https://aelder.dev/docs/openai-agents/
Service Base URL: https://aelder.dev/v1
First inspect my installed version, active profile and configuration. Explain any mismatch with the guide before changing anything.
Use the documented local configuration or CLI method. Do not automate the GUI, install software or change permissions without asking.
Preserve existing accounts, providers, models, defaults, permissions and unrelated settings. Propose the smallest change, show a redacted diff, and back up any files before editing.
Have me enter my API key locally using the tool's secret storage or an environment variable. Never ask me to paste a key into chat, print it, or include it in a command, diff, log or commit.
Use the exact model ID I choose from my account's model list. Do not invent model IDs or assume every model supports every API format or tool feature.
Validate syntax and configuration loading before making any generation request. If there is no dry-run, say so.
Explain any proposed paid test, the model and what it sends, and ask for approval before running it. Do not send project files or private conversation history as a test.
Finish with the settings changed, checks performed and steps to restore the backup.

The Python OpenAI Agents SDK accepts a custom OpenAI-compatible client. Use OpenAIChatCompletionsModel explicitly for Chat Completions; the SDK’s default OpenAI model path uses Responses instead.

This guide assumes the openai-agents package and its dependencies are installed in your Python environment. It covers an application you control, without changing other agents’ providers or tracing configuration.

1. Prepare local values

Set SERVICE_BASE_URL to the Base URL above, including /v1. Set SERVICE_MODEL_ID to an exact ID from the authenticated models endpoint. Supply SERVICE_API_KEY through your local secrets tooling, or read it in Bash or Zsh:

printf 'Service API key: '
IFS= read -r -s SERVICE_API_KEY
printf '\n'
export SERVICE_API_KEY

Start Python with these variables available. Keep the literal key out of source control and agent chats. A service key is not an OpenAI platform key.

2. Create a model for this agent

import asyncio
import os
from openai import AsyncOpenAI
from agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled

async def main():
    set_tracing_disabled(True)
    async with AsyncOpenAI(
        base_url=os.environ["SERVICE_BASE_URL"],
        api_key=os.environ["SERVICE_API_KEY"],
        max_retries=0,
    ) as client:
        agent = Agent(
            name="Service assistant",
            instructions="Answer briefly.",
            model=OpenAIChatCompletionsModel(
                model=os.environ["SERVICE_MODEL_ID"],
                openai_client=client,
            ),
        )
        result = await Runner.run(agent, "Reply with OK.")
        print(result.final_output)

asyncio.run(main())

The model ID is passed directly, including any slashes. Do not add a routing prefix. The client appends /chat/completions to its /v1 base URL.

The standalone example disables SDK tracing so it does not try to export traces to OpenAI using a service credential. This setting affects tracing for the process. In an existing application, review its tracing policy and custom processors before changing it.

3. Check configuration before running

Imports and constructing the client, model and agent check the local setup. Runner.run sends billable requests; tool loops, handoffs and retries can make more than one. Confirm the requested model and usage in your service dashboard before adding tools or other agents.

Recreate the model object to choose a different exact ID. Each agent or handoff target needs its intended model configuration. A text check does not verify tools, structured output, reasoning or images.

OpenAIResponsesModel is a separate option for compatible Responses models. Hosted tools, server-side conversation state and WebSocket transport require additional support; this Chat Completions setup does not establish it.

Sources: the SDK’s custom client and model configuration and official custom-provider example. The native configuration was reviewed; a live service run has not been verified.

Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.