Prerequisites:
- Python 3.12+
- A registered agent and an agent API key (
dome_...) — refer to Developer Quickstart - The gateway URL for the Gateway the agent is granted (
https://gateway.../gateways/{id})
Install
client.gateway.openai_client() lazy-imports openai; client.gateway.anthropic_client() lazy-imports anthropic. Install those packages only in agents that use the provider-native factories.
Initialize
Construct aClient with the agent token and gateway URL. The SDK does not read environment variables — pass values directly.
/gateways/{id} segment names the Gateway the agent is granted. Pass the complete URL returned by agent-key creation or token exchange. Bare roots and URLs ending in /mcp or /v1 raise DomeGatewayConfigurationError at connect() — the SDK does not compose a customer URL from an infrastructure endpoint.
connect() prepares token and transport state. It does not block on local policy sync — call start_policy_sync() only when you want in-process Cedar checks.
Call a tool
client.gateway.tools.call() runs an MCP tool through the gateway. Authorization, credential resolution, and audit happen server-side.
result.content is the raw tuple of MCP content blocks. By default, an upstream isError=true result raises DomeToolExecutionError. Pass raise_on_tool_error=False when you need the failed ToolCallResult and its partial content.
Call an LLM
client.gateway.llm.chat() posts OpenAI-shaped chat requests through the gateway. The response is the provider-shaped dict.
client.gateway.llm.messages(model=..., messages=..., max_tokens=...). For provider-native clients, refer to Reference.
Correlate work with an activity
Wrap a run inclient.activity(...) to stamp every gateway call and audit event with the same opaque activity ID.
Shut down
Always close the client to release transports.Next steps
Reference
Full client configuration, act-as methods, errors, and audit reads.
Tutorial
Wire the SDK into a service and verify in audit.
LangChain adapter
Use gateway tools and governed chat models inside LangChain agents.
Data plane concepts
How the gateway authorizes, resolves credentials, and audits every call.