---
title: LLM Connections
description: How to set up an LLM connection in Langfuse to use in the Playground or for LLM-as-a-Judge evaluations.
sidebarTitle: LLM Connections
---

# LLM Connections

LLM connections are used to call models in the Langfuse Playground or for LLM-as-a-Judge evaluations.

They do not affect the token prices of your ingested traces as cost is inferred from [model definitions](/docs/observability/features/token-and-cost-tracking#infer); to price a model that Langfuse does not ship a definition for, [add a custom model definition](/docs/observability/features/token-and-cost-tracking#custom-model-definitions), optionally with [pricing tiers](/docs/observability/features/token-and-cost-tracking#pricing-tiers).

## Setup

**Via the UI**

Choose where the connection should be available:

- **Organization connection**: Navigate to **Organization Settings > LLM Connections** to create a connection that every project in the organization inherits. Organization owners and admins can manage these connections.
- **Project connection**: Navigate to **Project Settings > LLM Connections** to create a connection for one project.

Click **Add new LLM API key**, then enter the connection name and the credentials for the model you want to use.

_[Video: Add an LLM connection](https://static.langfuse.com/docs-videos/2026-03-06-add-llm-connection-v3.mp4): Project Settings > “LLM Connections”. Click “+ Project Connection”, choose the LLM adapter (openai), enter a provider name (openai-support) and an API key, then click “Create connection”; Langfuse checks the key and the new connection appears under Project connections. “Show advanced settings” holds the base URL and custom models._

**Via the API**

You can use the [API](/docs/api-and-data-platform/features/public-api) to manage project connections with a project-scoped API key:

```bash
GET /api/public/llm-connections
PUT /api/public/llm-connections
DELETE /api/public/llm-connections/{id}
```

### Organization connections via API [#organization-connections-api]

**Where is this feature available?**

| Plan | Availability |
| --- | --- |
| Hobby | Not Available |
| Core | Not Available |
| Pro | Not Available |
| Enterprise | Available |
| Self Hosted | Enterprise Edition |

Use an [organization-scoped API key](/docs/administration/scim-and-org-api) to manage organization connections:

```bash
GET /api/public/organizations/llm-connections
PUT /api/public/organizations/llm-connections
DELETE /api/public/organizations/llm-connections/{id}
```

## Organization and project connections [#organization-and-project-connections]

Organization connections let you configure shared LLM credentials once for every project in an organization. Projects inherit each organization connection automatically.

A project connection with the same connection name overrides the organization connection for that project. The two connections must use the same provider adapter. For example, a project can override an organization connection named `openai-production` with different OpenAI credentials, a base URL, or custom models, but it cannot use the Anthropic adapter under that name.

Deleting the project override makes the project inherit the organization connection again. In **Project Settings > LLM Connections**, inherited and overridden connections are labeled so you can see which credentials the project uses.

## Supported providers

The Langfuse platform is currently supporting the following LLM providers:

- OpenAI
- Azure OpenAI
- Anthropic
- Google AI Studio
- Google Vertex AI
- Amazon Bedrock
- TypeSafe, directly or through Vercel AI Gateway or OpenRouter, for [Jev evaluators](/faq/all/decision-model-typesafe-jev)

When **Enable default models** is on, the provider's default models are available in the model selector of the Playground and evaluators. To use a model that is not in that list, e.g. a newer model, a fine-tuned model, or a model behind a proxy, add it under **Custom models** in the connection settings.

You may connect to third party LLM providers if their API schema implements the schema of one of our supported provider adapters. For example, you may connect to Mistral by using the OpenAI adapter in Langfuse to connect to Mistral's OpenAI compliant API.

### Amazon Bedrock [#amazon-bedrock]

Bedrock connections authenticate with AWS access keys, an [Amazon Bedrock API key](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html), or an [IAM role](#bedrock-iam-role). The credentials need the `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` permissions.

#### Authenticate with an IAM role [#bedrock-iam-role]

**Where is this feature available?**

| Plan | Availability |
| --- | --- |
| Hobby | Not Available |
| Core | Not Available |
| Pro | Not Available |
| Enterprise | Available |
| Self Hosted | Enterprise Edition |

Langfuse can assume an IAM role in your AWS account instead of storing AWS credentials. Langfuse assumes your role through its own cross-account role and passes an external ID that is unique to the connection. Set **Authentication Method** to **IAM role** and enter your role ARN. The Langfuse UI then shows the external ID and the trust and permission policies to add to the role. IAM role connections can only be created in the UI, not through the [public API](/docs/api-and-data-platform/features/public-api).

  On self-hosted deployments, an operator must set
  [`LANGFUSE_CROSS_ACCOUNT_ROLE_ARN`](/self-hosting/configuration#cross-account-role)
  to the role Langfuse assumes before it assumes your role. Without it, the
  **IAM role** option is disabled.

## Advanced configurations

### Additional provider options

  Provider options are **not set up in the Project Settings > LLM Connections**
  page but either when selecting a LLM Connection on the
  [Playground](/docs/prompt-management/features/playground) or during
  [LLM-as-a-Judge](/docs/evaluation/evaluation-methods/llm-as-a-judge) Evaluator
  setup.

LLM calls from a created LLM connection can be configured with a specific set of parameters, such as `temperature`, `top_p`, and `max_tokens`.

However, many LLM providers allow for additional parameters, including `reasoning_effort`, `service_tier`, and others when invoking a model. These parameters often differ between providers.

You can provide additional configurations as a JSON object for all LLM invocations. In the model parameters settings, you will find a "provider options" field at the bottom. This field allows you to enter specific key-value pairs accepted by your LLM provider's API endpoint.

Please see your providers API reference for what additional fields are supported:

- [Anthropic Messages API Reference](https://docs.anthropic.com/en/api/messages)
- [OpenAI Chat Completions API Reference](https://platform.openai.com/docs/api-reference/chat/create)
- [Google Gemini API Reference](https://ai.google.dev/api)
- [Google Vertex AI Gemini API Reference](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference)

This feature is currently available for the adapters for:

- Anthropic
- OpenAI
- Google AI Studio
- Google Vertex AI
- AWS (Amazon Bedrock)

Example for forcing reasoning effort `minimal` on an OpenAI gpt-5 invocation:

  ![Trace Detail](/images/docs/llm-connection-provider-options.png)

Example provider options for Google models (Google AI Studio and Google Vertex AI) to control thinking:

```json
{
  "thinkingLevel": "MEDIUM",
  "thinkingBudget": 2048
}
```

`thinkingLevel` controls the reasoning depth, and `thinkingBudget` sets the token budget for thinking. These options are only valid for Google models that support thinking.

### Troubleshooting: "Blocked IP address detected" [#blocked-ip-address]

Langfuse validates the base URL of every LLM connection against a server-side request forgery (SSRF) deny-list before it calls the endpoint on your behalf. The check runs when you save or test a connection, and again on every outbound request from the Playground, LLM-as-a-Judge evaluators, and experiments, including on each redirect.

A URL is rejected with `Blocked IP address detected` (or `Blocked hostname detected`) when its hostname resolves to a private, loopback, link-local, or otherwise reserved range — for example `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `127.0.0.0/8`, `169.254.0.0/16`, and their IPv6 equivalents — or when the hostname itself is blocked, such as `localhost`, `*.internal`, or `host.docker.internal`. Public IP addresses and public hostnames are not blocked. A hostname that does not resolve is rejected as well.

- **Langfuse Cloud**: the deny-list is always enforced and cannot be relaxed, and base URLs must use `https://`. Point the connection at a publicly resolvable endpoint, for example a gateway with a public hostname.
- **Self-hosted**: allow specific internal endpoints with `LANGFUSE_LLM_CONNECTION_WHITELISTED_HOST`, `LANGFUSE_LLM_CONNECTION_WHITELISTED_IPS`, or `LANGFUSE_LLM_CONNECTION_WHITELISTED_IP_SEGMENTS`, or restrict outbound LLM requests to a non-empty positive host list with `LANGFUSE_LLM_CONNECTION_ALLOWED_HOSTS` (each a comma-separated list). A hostname listed in `_WHITELISTED_HOST` skips the IP check entirely; `_IPS` and `_IP_SEGMENTS` are matched against every IP address the hostname resolves to; `_ALLOWED_HOSTS` permits only the listed hostnames (which also bypass the private-IP check) and rejects all other hosts, including provider default hosts and Langfuse AI ([Halo](/self-hosting/configuration/halo), the Langfuse assistant, uses its own provider client and is not covered). There is no setting that disables the check for all targets: every internal endpoint has to be listed explicitly, because anything on these lists is exempt from SSRF protection. Webhooks, blob storage integrations, and external media storage use their own variables; see [Outbound URL allowlists](/self-hosting/configuration/hardening#outbound-url-allowlists).

### Connecting via a gateway

If you route LLM calls through an OpenAI-compatible gateway such as [LiteLLM](/integrations/gateways/litellm), [OpenRouter](/integrations/gateways/openrouter), or [Portkey](/integrations/gateways/portkey), you can use it as your LLM connection for the Playground and LLM-as-a-Judge evaluations.

To set this up:

1. Navigate to **Project Settings** > **LLM Connections** and click **Add new LLM API key**.
2. Select **OpenAI** as the provider.
3. Enter the API key for your gateway.
4. Under **Advanced Settings**, set the **Base URL** to your gateway's endpoint, e.g. `https://your-litellm-instance.com/v1`.
5. Add any **custom model names** that your gateway exposes.

  The gateway must support [tool
  calling](https://platform.openai.com/docs/guides/function-calling) in the
  OpenAI format for LLM-as-a-Judge evaluations to work.

For OpenAI-compatible gateways, here is an example tool calling request that must be handled by the gateway to support LLM-as-a-Judge in Langfuse:

```bash /<host set in project settings>/ /<api key entered in project settings>/ /<custom header set in project settings>/ /<model set in project settings>/
curl -X POST 'https://<host set in project settings>/chat/completions' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'authorization: Bearer <api key entered in project settings>' \
-H 'x-test-header-1: <custom header set in project settings>' \
-H 'x-test-header-2: <custom header set in project settings>' \
-d '{
  "model": "<model set in project settings>",
  "temperature": 0,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "max_tokens": 256,
  "n": 1,
  "stream": false,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "extract",
        "parameters": {
          "type": "object",
          "properties": {
            "score": {
              "type": "string"
            },
            "reasoning": {
              "type": "string"
            }
          },
          "required": [
            "score",
            "reasoning"
          ],
          "additionalProperties": false,
          "$schema": "http://json-schema.org/draft-07/schema#"
        }
      }
    }
  ],
  "tool_choice": {
    "type": "function",
    "function": {
      "name": "extract"
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Evaluate the correctness of the generation on a continuous scale from 0 to 1. A generation can be considered correct (Score: 1) if it includes all the key facts from the ground truth and if every fact presented in the generation is factually supported by the ground truth or common sense.\n\nExample:\nQuery: Can eating carrots improve your vision?\nGeneration: Yes, eating carrots significantly improves your vision, especially at night. This is why people who eat lots of carrots never need glasses. Anyone who tells you otherwise is probably trying to sell you expensive eyewear or does not want you to benefit from this simple, natural remedy. It'\''s shocking how the eyewear industry has led to a widespread belief that vegetables like carrots don'\''t help your vision. People are so gullible to fall for these money-making schemes.\nGround truth: Well, yes and no. Carrots won'\''t improve your visual acuity if you have less than perfect vision. A diet of carrots won'\''t give a blind person 20/20 vision. But, the vitamins found in the vegetable can help promote overall eye health. Carrots contain beta-carotene, a substance that the body converts to vitamin A, an important nutrient for eye health.  An extreme lack of vitamin A can cause blindness. Vitamin A can prevent the formation of cataracts and macular degeneration, the world'\''s leading cause of blindness. However, if your vision problems aren'\''t related to vitamin A, your vision won'\''t change no matter how many carrots you eat.\nScore: 0.1\nReasoning: While the generation mentions that carrots can improve vision, it fails to outline the reason for this phenomenon and the circumstances under which this is the case. The rest of the response contains misinformation and exaggerations regarding the benefits of eating carrots for vision improvement. It deviates significantly from the more accurate and nuanced explanation provided in the ground truth.\n\n\n\nInput:\nQuery: {{query}}\nGeneration: {{generation}}\nGround truth: {{ground_truth}}\n\n\nThink step by step."
    }
  ]
}'
```

### OpenAI Responses API endpoints

Some OpenAI-compatible providers expose the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses) instead of the Chat Completions API. For these providers, enable **Use Responses API** on the OpenAI LLM Connection so Langfuse sends Playground, LLM-as-a-Judge, and prompt experiment requests through the Responses API.

For example, to use OpenAI models on Amazon Bedrock through the Bedrock Mantle endpoint:

1. Navigate to **Project Settings** > **LLM Connections** and click **Add new LLM API key**.
2. Select **OpenAI** as the provider.
3. Enter your [Amazon Bedrock API key](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html).
4. Under **Advanced Settings**, set the **Base URL** to `https://bedrock-mantle.<aws-region>.api.aws/openai/v1`.
5. Enable **Use Responses API**.
6. Add the **custom model names** available in your Bedrock account, for example `openai.gpt-5.5` or `openai.gpt-5.4`.

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/docs/administration/llm-connection.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx @langfuse/cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
