Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,29 @@
"label": "AI Gateway",
"items": [
{ "label": "Overview", "slug": "reference/advanced/gateway/index" },
{ "label": "Embeddings", "slug": "reference/advanced/gateway/embeddings" }
{ "label": "Embeddings", "slug": "reference/advanced/gateway/embeddings" },
{
"label": "Integrations",
"items": [
{ "label": "Overview", "slug": "reference/advanced/gateway/integrations/index" },
{ "label": "Agno", "slug": "reference/advanced/gateway/integrations/agno" },
{ "label": "Genkit", "slug": "reference/advanced/gateway/integrations/genkit" },
{ "label": "Google ADK", "slug": "reference/advanced/gateway/integrations/google-adk" },
{ "label": "Haystack", "slug": "reference/advanced/gateway/integrations/haystack" },
{ "label": "Instructor", "slug": "reference/advanced/gateway/integrations/instructor" },
{ "label": "LangChain", "slug": "reference/advanced/gateway/integrations/langchain" },
{ "label": "LlamaIndex", "slug": "reference/advanced/gateway/integrations/llamaindex" },
{ "label": "Mastra", "slug": "reference/advanced/gateway/integrations/mastra" },
{ "label": "Microsoft Agent Framework", "slug": "reference/advanced/gateway/integrations/microsoft-agent-framework" },
{ "label": "OpenAI Agents SDK", "slug": "reference/advanced/gateway/integrations/openai-agents-sdk" },
{ "label": "OpenAI SDK", "slug": "reference/advanced/gateway/integrations/openai-sdk" },
{ "label": "Semantic Kernel", "slug": "reference/advanced/gateway/integrations/semantic-kernel" },
{ "label": "Smolagents", "slug": "reference/advanced/gateway/integrations/smolagents" },
{ "label": "Strands Agents", "slug": "reference/advanced/gateway/integrations/strands-agents" },
{ "label": "Vercel AI SDK", "slug": "reference/advanced/gateway/integrations/vercel-ai-sdk" },
{ "label": "VoltAgent", "slug": "reference/advanced/gateway/integrations/voltagent" }
]
}
]
}
]
Expand Down
53 changes: 53 additions & 0 deletions docs/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,59 @@ navigation:
- page: "Embeddings"
path: "reference/advanced/gateway/embeddings.md"
slug: "manage/ai-gateway/embeddings"
- section: "Integrations"
contents:
- page: "Overview"
path: "reference/advanced/gateway/integrations/index.md"
slug: "manage/ai-gateway/integrations"
- page: "Agno"
path: "reference/advanced/gateway/integrations/agno.md"
slug: "manage/ai-gateway/integrations/agno"
- page: "Genkit"
path: "reference/advanced/gateway/integrations/genkit.md"
slug: "manage/ai-gateway/integrations/genkit"
- page: "Google ADK"
path: "reference/advanced/gateway/integrations/google-adk.md"
slug: "manage/ai-gateway/integrations/google-adk"
- page: "Haystack"
path: "reference/advanced/gateway/integrations/haystack.md"
slug: "manage/ai-gateway/integrations/haystack"
- page: "Instructor"
path: "reference/advanced/gateway/integrations/instructor.md"
slug: "manage/ai-gateway/integrations/instructor"
- page: "LangChain"
path: "reference/advanced/gateway/integrations/langchain.md"
slug: "manage/ai-gateway/integrations/langchain"
- page: "LlamaIndex"
path: "reference/advanced/gateway/integrations/llamaindex.md"
slug: "manage/ai-gateway/integrations/llamaindex"
- page: "Mastra"
path: "reference/advanced/gateway/integrations/mastra.md"
slug: "manage/ai-gateway/integrations/mastra"
- page: "Microsoft Agent Framework"
path: "reference/advanced/gateway/integrations/microsoft-agent-framework.md"
slug: "manage/ai-gateway/integrations/microsoft-agent-framework"
- page: "OpenAI Agents SDK"
path: "reference/advanced/gateway/integrations/openai-agents-sdk.md"
slug: "manage/ai-gateway/integrations/openai-agents-sdk"
- page: "OpenAI SDK"
path: "reference/advanced/gateway/integrations/openai-sdk.md"
slug: "manage/ai-gateway/integrations/openai-sdk"
- page: "Semantic Kernel"
path: "reference/advanced/gateway/integrations/semantic-kernel.md"
slug: "manage/ai-gateway/integrations/semantic-kernel"
- page: "Smolagents"
path: "reference/advanced/gateway/integrations/smolagents.md"
slug: "manage/ai-gateway/integrations/smolagents"
- page: "Strands Agents"
path: "reference/advanced/gateway/integrations/strands-agents.md"
slug: "manage/ai-gateway/integrations/strands-agents"
- page: "Vercel AI SDK"
path: "reference/advanced/gateway/integrations/vercel-ai-sdk.md"
slug: "manage/ai-gateway/integrations/vercel-ai-sdk"
- page: "VoltAgent"
path: "reference/advanced/gateway/integrations/voltagent.md"
slug: "manage/ai-gateway/integrations/voltagent"
- section: "Observability"
slug: ""
contents:
Expand Down
49 changes: 49 additions & 0 deletions docs/reference/advanced/gateway/integrations/agno.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "Connect Agno to the AI Gateway"
description: "Send Agno model requests through the Logfire AI Gateway."
---

# Connect Agno to the AI Gateway

Send requests from your Agno agents through the Logfire AI Gateway.

[Agno](https://docs.agno.com/) is a Python framework for building multimodal and multi-agent AI systems. The example keeps the agent in Agno and points its `OpenAIChat` model at an OpenAI-compatible gateway route.

## Before you start

- Complete the [AI Gateway prerequisites](index.md#before-you-start), including setting `LOGFIRE_GATEWAY_API_KEY` in your terminal.
- Use an existing Agno project with the packages imported below installed.

!!! note "Model data passes through Logfire"
This configuration sends prompts, tool inputs, and model responses through the Logfire AI Gateway and the selected model provider. If gateway telemetry is enabled, Logfire stores the conversation content in your selected project. Calls to built-in providers count toward your gateway spend.

## Configure Agno

Set `api_key` to your gateway key and `base_url` to the OpenAI-compatible gateway route. Copy the route and a supported model name from the Gateway **Connect** tab.

```python title="agno-gateway.py" hl_lines="10-11" skip-run="true" skip-reason="external-connection"
import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat

agent = Agent(
name='Weather Agent',
model=OpenAIChat(
id='gpt-5.4-mini',
api_key=os.environ['LOGFIRE_GATEWAY_API_KEY'],
base_url='https://gateway-us.pydantic.dev/proxy/openai',
),
)

agent.print_response('What is the weather in London?')
```

## Verify it worked

Run the example from your terminal. It prints the model response. That confirms the client reached the gateway. Organization admins can also open **AI Engineering** > **Gateway** > **Spending** to see usage for the key. If telemetry is enabled, open the selected project's **Live** view to inspect the request trace.

## Troubleshooting

- **Python raises `KeyError: 'LOGFIRE_GATEWAY_API_KEY'`:** set the environment variable in the same terminal where you run the example.
- **The request returns an authentication or model error:** copy the URL and model name again from the Gateway **Connect** tab, and confirm that the selected route supports the OpenAI request format.
107 changes: 107 additions & 0 deletions docs/reference/advanced/gateway/integrations/genkit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: "Connect Genkit to the AI Gateway"
description: "Send Genkit model requests through the Logfire AI Gateway."
---

# Connect Genkit to the AI Gateway

Send requests from your Genkit application through the Logfire AI Gateway.

[Genkit](https://genkit.dev/) is Google's open-source framework for building AI applications. Both examples configure Genkit's OpenAI-compatible plugin with a gateway key and route.

## Before you start

- Complete the [AI Gateway prerequisites](index.md#before-you-start), including setting `LOGFIRE_GATEWAY_API_KEY` in your terminal.
- Use an existing Genkit project with the packages imported by your chosen example installed.

!!! note "Model data passes through Logfire"
This configuration sends prompts, tool inputs, and model responses through the Logfire AI Gateway and the selected model provider. If gateway telemetry is enabled, Logfire stores the conversation content in your selected project. Calls to built-in providers count toward your gateway spend.

## TypeScript

Set `apiKey` to your gateway key and `baseURL` to the OpenAI-compatible gateway route. Copy the route and a supported model name from the Gateway **Connect** tab.

```typescript title="genkit-gateway.mts" hl_lines="15-16" skip-run="true" skip-reason="external-connection"
import { openAICompatible } from '@genkit-ai/compat-oai';
import { genkit } from 'genkit';
import { z } from 'zod';

const envSchema = z.object({
LOGFIRE_GATEWAY_API_KEY: z.string(),
});

const env = envSchema.parse(process.env);

const ai = genkit({
plugins: [
openAICompatible({
name: 'openai',
apiKey: env.LOGFIRE_GATEWAY_API_KEY,
baseURL: 'https://gateway-us.pydantic.dev/proxy/openai',
}),
],
});

const { text } = await ai.generate({
model: 'openai/gpt-5.4-mini',
prompt: 'What is the weather in London?',
});

console.log(text);
```

## Go

Pass the same gateway key and route to Genkit's Go plugin.

```go title="genkit-gateway.go" hl_lines="25 27" skip-run="true" skip-reason="external-connection"
package main

import (
"context"
"log"
"os"
"time"

"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/compat_oai/openai"
"github.com/openai/openai-go/option"
)

func main() {
apiKey := os.Getenv("LOGFIRE_GATEWAY_API_KEY")
if apiKey == "" {
log.Fatal("LOGFIRE_GATEWAY_API_KEY is required")
}

ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

g := genkit.Init(ctx, genkit.WithPlugins(&openai.OpenAI{
APIKey: apiKey,
Opts: []option.RequestOption{
option.WithBaseURL("https://gateway-us.pydantic.dev/proxy/openai"),
},
}))

response, err := genkit.Generate(ctx, g,
ai.WithPrompt("What is the weather in London?"),
ai.WithModelName("openai/gpt-5.4-mini"),
)
if err != nil {
log.Fatal(err)
}

log.Println(response.Text())
}
```

## Verify it worked

Run either example from your terminal. It prints the model response. That confirms the client reached the gateway. Organization admins can also open **AI Engineering** > **Gateway** > **Spending** to see usage for the key. If telemetry is enabled, open the selected project's **Live** view to inspect the request trace.

## Troubleshooting

- **The example reports that `LOGFIRE_GATEWAY_API_KEY` is missing:** set the environment variable in the same terminal where you run the example.
- **The request returns an authentication or model error:** copy the URL and model name again from the Gateway **Connect** tab, and confirm that the selected route supports the OpenAI request format.
138 changes: 138 additions & 0 deletions docs/reference/advanced/gateway/integrations/google-adk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: "Connect Google ADK to the AI Gateway"
description: "Send Google ADK model requests through the Logfire AI Gateway."
---

# Connect Google ADK to the AI Gateway

Send requests from your Google Agent Development Kit (ADK) agents through the Logfire AI Gateway.

[Google ADK](https://adk.dev/) is Google's framework for building multi-step and multi-agent AI systems. The Python example uses LiteLLM, a library that translates between model-provider APIs. The Go example connects directly to the gateway's Google Vertex route.

## Before you start

- Complete the [AI Gateway prerequisites](index.md#before-you-start), including setting `LOGFIRE_GATEWAY_API_KEY` in your terminal.
- Use an existing Google ADK project with the packages imported by your chosen example installed.

!!! note "Model data passes through Logfire"
This configuration sends prompts, tool inputs, and model responses through the Logfire AI Gateway and the selected model provider. If gateway telemetry is enabled, Logfire stores the conversation content in your selected project. Calls to built-in providers count toward your gateway spend.

## Python

The LiteLLM client uses the OpenAI-compatible gateway route. Copy the route and a supported model name from the Gateway **Connect** tab.

```python title="google-adk-gateway.py" hl_lines="9-10" skip-run="true" skip-reason="external-connection"
import asyncio
import os

from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from google.adk.runners import InMemoryRunner
from google.genai import types

os.environ['OPENAI_API_KEY'] = os.environ['LOGFIRE_GATEWAY_API_KEY']
os.environ['OPENAI_BASE_URL'] = 'https://gateway-us.pydantic.dev/proxy/openai'

agent = LlmAgent(
model=LiteLlm(model='openai/gpt-5.4-mini'),
name='weather_agent',
instruction='You are a concise weather assistant.',
)


async def main() -> None:
runner = InMemoryRunner(agent=agent)
session = await runner.session_service.create_session(
app_name=runner.app_name,
user_id='gateway-example-user',
)
content = types.Content(
role='user',
parts=[types.Part.from_text(text='What is the weather in London?')],
)
async for event in runner.run_async(
user_id=session.user_id,
session_id=session.id,
new_message=content,
):
if event.is_final_response() and event.content and event.content.parts:
print(event.content.parts[0].text)


if __name__ == '__main__':
asyncio.run(main())
```

## Go

The Go client uses the provider-native Google Vertex route. Copy the Google Vertex URL and a supported Gemini model from the Gateway **Connect** tab.

```go title="google-adk-gateway.go" hl_lines="17 25 28 30" skip-run="true" skip-reason="external-connection"
package main

import (
"context"
"fmt"
"log"
"net/http"
"os"
"time"

adkmodel "google.golang.org/adk/v2/model"
"google.golang.org/adk/v2/model/gemini"
"google.golang.org/genai"
)

func main() {
apiKey := os.Getenv("LOGFIRE_GATEWAY_API_KEY")
if apiKey == "" {
log.Fatal("LOGFIRE_GATEWAY_API_KEY is required")
}

ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

model, err := gemini.NewModel(ctx, "gemini-2.5-flash", &genai.ClientConfig{
Backend: genai.BackendVertexAI,
HTTPOptions: genai.HTTPOptions{
BaseURL: "https://gateway-us.pydantic.dev/proxy/google-vertex",
Headers: http.Header{
"Authorization": []string{"Bearer " + apiKey},
},
},
})
if err != nil {
panic(err)
}

request := &adkmodel.LLMRequest{
Contents: []*genai.Content{
genai.NewContentFromText("What is the weather in London?", genai.RoleUser),
},
}

for response, err := range model.GenerateContent(ctx, request, false) {
if err != nil {
panic(err)
}
if response.Content == nil {
continue
}
for _, part := range response.Content.Parts {
if part.Text != "" {
fmt.Println(part.Text)
}
}
}
}
```

## Verify it worked

Run either example from your terminal. It prints the model response. That confirms the client reached the gateway. Organization admins can also open **AI Engineering** > **Gateway** > **Spending** to see usage for the key. If telemetry is enabled, open the selected project's **Live** view to inspect the request trace.

## Troubleshooting

- **The example reports that `LOGFIRE_GATEWAY_API_KEY` is missing:** set the environment variable in the same terminal where you run the example.
- **The Python request fails:** copy an OpenAI-compatible URL and supported model from the Gateway **Connect** tab.
- **The Go request fails:** copy the Google Vertex URL and supported Gemini model from the **Connect** tab; an OpenAI-compatible route does not work with the provider-native Go client.
Loading
Loading