Skip to Content
Launching the open-source gateway

Instructor (gateway)

Route Instructor’s underlying OpenAI-compatible LLM calls through the Respan gateway to use 1000+ models from different providers. Only your Respan API key is needed - no separate provider key is required.

Paste this into your coding agent:

Help me set up the Respan gateway with the Instructor integration. Follow https://www.respan.ai/docs/integrations/gateway/instructor.md

Setup

Install packages

Terminal
pip install instructor openai

Set environment variables

Terminal
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY" export RESPAN_BASE_URL="https://api.respan.ai/api"

No OPENAI_API_KEY is needed when the request is routed through the Respan gateway.

Point Instructor to the Respan gateway

Python
import os from typing import TypedDict import instructor client = instructor.from_provider( "openai/gpt-5-mini", api_key=os.environ["RESPAN_API_KEY"], base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"), mode=instructor.Mode.TOOLS, ) class Person(TypedDict): name: str role: str person = client.create( response_model=Person, messages=[ { "role": "user", "content": "Grace Hopper was a pioneering computer scientist.", } ], ) print(dict(person))

Switch models

Change the model string passed to instructor.from_provider to use another OpenAI model through the same gateway endpoint.

Python
client = instructor.from_provider( "openai/gpt-5.5", api_key=os.environ["RESPAN_API_KEY"], base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"), mode=instructor.Mode.TOOLS, )

Instructor’s from_provider string includes the SDK provider namespace. Keep this page to OpenAI models so Claude or Gemini are not shown as OpenAI-provider models. Use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.

See the full model list .