OpenAI Agents SDK
The OpenAI Agents SDK builds agents that use tools. It can use any model on MAG through the Chat Completions API.
Install the SDK:
python -m pip install openai-agents
Set OPENAI_API_KEY and OPENAI_BASE_URL as shown in LLM SDKs. Then run this Python code:
from agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled
from openai import AsyncOpenAI
# Tracing uploads to OpenAI. MAG does not support it.
set_tracing_disabled(True)
client = AsyncOpenAI()
agent = Agent(
name="Assistant",
instructions="Answer in one sentence.",
model=OpenAIChatCompletionsModel(model="claude-sonnet", openai_client=client),
)
print(Runner.run_sync(agent, "What is an AI agent?").final_output)
The code prints the response of the agent. To use a different model, change the model value.