Skip to content

Connect frameworks to the AI Gateway

Connect the framework, prompts, tools, and agent workflow you already use to the Logfire AI Gateway.

Each guide shows the two client settings you need to change: the API key and gateway URL. You can point them at one model provider or at a routing group, which can fail over to another provider or distribute requests across several providers.

Before you start

  1. If your organization has not enabled the gateway, follow Enable the gateway. You need to be an organization admin.

  2. In Logfire, open your organization, then select AI Engineering > Gateway > API Keys.

  3. Create or copy a gateway API key, then set it in the terminal where you will run the example:

    Terminal
    export LOGFIRE_GATEWAY_API_KEY="..."
    
  4. On the Gateway Connect tab, select a provider and model. Copy the gateway URL and model name into the example.

The examples use the OpenAI-compatible route for the US region, https://gateway-us.pydantic.dev/proxy/openai. For the EU region, use gateway-eu instead. For a self-hosted organization, copy the URL from the Connect tab.

Most examples use an OpenAI-compatible client. The provider or routing group you select must support the OpenAI request format and the model name in the example. Provider-native APIs, such as Anthropic Messages, require that provider’s client. See Connect an SDK for both patterns.

Choose your framework

Framework or SDKLanguages
AgnoPython
GenkitGo, TypeScript
Google ADKGo, Python
HaystackPython
InstructorPython
LangChainTypeScript, Python
LlamaIndexPython
MastraTypeScript
Microsoft Agent Framework.NET, Python
OpenAI Agents SDKTypeScript, Python
OpenAI SDK.NET, Go, TypeScript, Python
Semantic Kernel.NET, Python
SmolagentsPython
Strands AgentsTypeScript, Python
Vercel AI SDKTypeScript
VoltAgentTypeScript

Next steps

Read the AI Gateway overview to learn how providers, routing groups, spending limits, and telemetry work together.