AgentSpec (gateway)

Route AgentSpec’s underlying LLM calls through the Respan gateway to use 250+ models from different providers. Only your RESPAN_API_KEY is needed — no separate provider keys required.

Setup

1

Install packages

$pip install "pyagentspec[langgraph]"
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No OPENAI_API_KEY needed — the Respan gateway handles provider authentication.

3

Point AgentSpec to the Respan gateway

1import os
2from pyagentspec.adapters.langgraph import AgentSpecLoader
3from pyagentspec.agent import Agent
4from pyagentspec.llms import OpenAiConfig
5
6os.environ["OPENAI_API_KEY"] = os.environ["RESPAN_API_KEY"]
7os.environ["OPENAI_BASE_URL"] = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
8
9agent = Agent(
10 name="haiku_assistant",
11 description="A helpful assistant that writes haikus.",
12 llm_config=OpenAiConfig(name="openai", model_id="gpt-5.5"),
13 system_prompt="You are a helpful assistant. Respond only with a haiku.",
14)
15
16langgraph_agent = AgentSpecLoader().load_component(agent)
17result = langgraph_agent.invoke(
18 input={"messages": [{"role": "user", "content": "Write a haiku about recursion."}]}
19)
20print(result["messages"][-1].content)

Switch models

Change the model_id parameter on OpenAiConfig to use another OpenAI model through the same gateway-backed configuration.

1llm_config = OpenAiConfig(name="openai", model_id="gpt-5.5")

AgentSpec’s OpenAiConfig(name="openai", ...) is provider-specific configuration. This page avoids showing Claude or Gemini under that provider name; use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.

See the full model list.