Skip to content
BotServBotServ
OpenAI Agents SDKAI AgentFrameworkCloudAgentic AI

OpenAI Agents SDK

Install OpenAI Agents SDK and build your first agents. Get started with agents, tools, and workflows.

S

schutzgeist

2 min read
OpenAI Agents SDK

OpenAI Agents SDK

What This Article Covers

  • What the OpenAI Agents SDK is and why you’d use it.
  • How to install it.
  • How to build your first agent with a tool.
  • How to work locally or with the OpenAI API.
  • Where it excels and what its limitations are.

Introduction

The OpenAI Agents SDK is OpenAI’s official Python framework for building agents. It provides tool-calling capabilities, state management, and workflow orchestration. Installation is straightforward, and you can get started quickly. If you want to jump straight into working with powerful models, this is a solid choice. You can also run it locally via OpenAI-compatible endpoints like Ollama, though the framework is primarily designed around OpenAI’s APIs.

OpenAI Agents SDK at a Glance

The SDK works with agents, tools, and runners. An agent receives instructions and can invoke tools. A runner executes requests and manages the workflow. Tools are Python functions that the agent can call. This lets you build an agent that can research, perform calculations, or consume external APIs.

Installation

pip install openai-agents

To use OpenAI, you’ll need an API key:

export OPENAI_API_KEY="your-key"

If you want to use an OpenAI-compatible local model like Ollama, also set the base URL:

export OPENAI_BASE_URL="http://localhost:11434/v1"

Getting Started: An Agent with a Tool

from agents import Agent, Runner

def current_year() -> str:
    return "2026"

agent = Agent(
    name="helpful_assistant",
    instructions="You help answer simple questions.",
    tools=[current_year]
)

result = Runner.run_sync(agent, "What year is it?")
print(result.final_output)

In this example, you register a Python function as a tool. The agent decides on its own whether to call it.

What Is This SDK Good For?

Use CaseBenefit
Quick prototypesSimple tool-calling and runner API
Cloud agentsDirect integration with OpenAI models
API workflowsAgents access your own functions
LearningMinimal boilerplate, fast results

Common Pitfalls

  • API costs - OpenAI models aren’t free. For local testing, integrate Ollama instead.
  • No native multi-agent orchestration - For complex multi-agent teams, CrewAI or AutoGen are often more flexible.
  • Base URL matters - With Ollama, the URL must end with /v1 and any API key will work.

Further Reading

FAQ - Common Questions

Is the OpenAI Agents SDK free?

The SDK itself is free. Costs only appear when you use the OpenAI API. Local models via Ollama are free.

Can I run it locally?

Yes, via OpenAI-compatible endpoints like Ollama. Set OPENAI_BASE_URL to http://localhost:11434/v1.

What do I need to get started?

Python, pip install openai-agents, and either an OpenAI API key or a local Ollama model.

Sources

Back to Blog
Share:

Nächster Artikel in AI Agents

Weiterlesen
OpenClaw

Related Posts