OpenAI Agents SDK

The OpenAI Agents SDKarrow-up-right enables you to build agentic AI apps in a lightweight, easy-to-use package with very few abstractions. It's a production-ready upgrade of our previous experimentation for agents, Swarm. The Agents SDK has a very small set of primitives:

  • Agents, which are LLMs equipped with instructions and tools

  • Handoffs, which allow agents to delegate to other agents for specific tasks

  • Guardrails, which enable validation of agent inputs and outputs

  • Sessions, which automatically maintains conversation history across agent runs

Sample implementation using nexos.ai

  • Install dependencies

  • Define environments NEXOS_API_KEY=team-api-key NEXOS_BASE_URL=https://api.nexos.ai/v1.

import os

from agents import Agent, Runner, set_tracing_disabled, OpenAIChatCompletionsModel, AsyncOpenAI
from dotenv import load_dotenv

set_tracing_disabled(True)

# Load environment variables from .env file
load_dotenv()
# --- Configuration ---
NEXOS_BASE_URL = os.getenv("NEXOS_BASE_URL")
NEXOS_API_KEY = os.getenv("NEXOS_API_KEY")
if not NEXOS_BASE_URL or not NEXOS_API_KEY:
    raise ValueError("Please set NEXOS_BASE_URL and NEXOS_API_KEY in your .env file")

client = AsyncOpenAI(api_key=NEXOS_API_KEY, base_url=NEXOS_BASE_URL)
model = OpenAIChatCompletionsModel(model="GPT 5 mini", openai_client=client)

agent = Agent(name="Assistant", instructions="You are a helpful assistant", model=model)

result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
print(result.final_output)

You can use any open AI compatible model. To check what models are available for you, call Gateway API | nexos.ai documentationarrow-up-right You can use either nexos_model_idor id as model.

Last updated