Skip to main content

Using the OpenAI Agents SDK

This guide explains how to use the OpenAI Agents SDK with model endpoints deployed on the E2E Networks Inference platform using vLLM and tool calling support.


Step 1: Create a Model Endpoint

  1. Go to the AI Platform
  2. Navigate to Model Endpoints
  3. Click Create Endpoint
  4. Select vLLM Framework
  5. Choose your preferred model (example: Llama‑3.3‑70B‑Instruct)
  6. Choose a GPU plan and replicas

Enable Tool Calling

Under LLM Settings:

  • Enable Auto Tool Choice
  • Select a Tool Call Parser (e.g., llama4_pythonic, mistral)

Launch the endpoint and wait for the status to show Running.


Step 2: Connect via OpenAI Agents SDK

Use a custom model provider to send API requests directly to your endpoint.

BASE_URL = "https://infer.e2enetworks.net/project/{project_id}/endpoint/{inference_id}/v1"
API_KEY=""
MODEL_NAME = "meta-llama/Llama-3.3-70B-Instruct"

if not BASE_URL or not API_KEY or not MODEL_NAME:
raise ValueError("Configure BASE_URL, API_KEY, MODEL_NAME appropriately.")

client = AsyncOpenAI(base_url=BASE_URL, api_key=API_KEY)
set_tracing_disabled(disabled=True)

class CustomModelProvider(ModelProvider):
def get_model(self, model_name: str | None) -> Model:
return OpenAIChatCompletionsModel(model=model_name or MODEL_NAME, openai_client=client)

CUSTOM_MODEL_PROVIDER = CustomModelProvider()

Example 1: Customer Service Agent

A multi-agent chatbot handling:

  • Seat booking
  • Airline FAQs
  • Automatic delegation between agents

Tools used:

  • faq_lookup_tool
  • update_seat

Run example:

python customer_service_agent.py

Example 2: Research Bot Agent

Performs automated: ✅ Web search planning ✅ Parallel searching ✅ AI‑generated report writing

Repo Setup

git clone https://github.com/openai/openai-agents-python.git
cd openai-agents-python

Modify Model Configurations

Inside example files, remove existing model config lines like:

# model="gpt-4o"
# model="o3-mini"

Use Custom Provider in manager.py

result = await Runner.run(
planner_agent,
f"Query: {query}",
run_config=RunConfig(model_provider=CUSTOM_MODEL_PROVIDER),
)

To run:

python examples/research_bot/manager.py

Notes

  • Works with most open‑weights models (LLaMA, Mixtral, etc.)
  • Endpoint must have tool calling enabled
  • Tools must be registered using @function_tool

Example Use Cases

  • Airline and travel support bots
  • Automated research assistants
  • Multi‑agent domain‑specific workflows

Resources

  • OpenAI Agents SDK
  • vLLM Documentation

Tips

  • Use Pydantic models for structured I/O
  • Disable tracing in production to reduce logs
  • Maintain context using RunContextWrapper