LLM 连接
LLM 连接用于在 Litefuse Playground 或 LLM-as-a-Judge 评估中调用模型。
配置
- 进入
Project Settings>LLM Connections,点击Add new LLM API key。 - 输入 LLM 连接的名称以及你想使用的模型对应的 API Key。
支持的提供商
Litefuse 平台目前支持以下 LLM 提供商:
- OpenAI
- Azure OpenAI
- Anthropic
- Google AI Studio
- Google Vertex AI
- Amazon Bedrock
支持的模型
目前 Playground 默认支持以下模型。当你在 Litefuse 项目设置中添加 LLM API Key 时,可以配置额外的自定义模型名称,例如使用自定义模型或代理时。
- 任何兼容 OpenAI API schema 的模型: Playground 与 LLM-as-a-Judge 评估可与任何兼容 OpenAI API schema 的框架配合使用,例如 Groq、OpenRouter、Vercel AI Gateway、LiteLLM、Hugging Face 等。只需把 API Base URL 替换为目标模型的对应 endpoint,并填入提供商的 API Key 进行认证即可。
- OpenAI / Azure OpenAI: o3, o3-2025-04-16, o4-mini, o4-mini-2025-04-16, gpt-4.1, gpt-4.1-2025-04-14, gpt-4.1-mini-2025-04-14, gpt-4.1-nano-2025-04-14, gpt-4o, gpt-4o-2024-08-06, gpt-4o-2024-05-13, gpt-4o-mini, gpt-4o-mini-2024-07-18, o3-mini, o3-mini-2025-01-31, o1-preview, o1-preview-2024-09-12, o1-mini, o1-mini-2024-09-12, gpt-4-turbo-preview, gpt-4-1106-preview, gpt-4-0613, gpt-4-0125-preview, gpt-4, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-1106, gpt-3.5-turbo-0613, gpt-3.5-turbo-0301, gpt-3.5-turbo-0125, gpt-3.5-turbo
- Anthropic: claude-3-7-sonnet-20250219, claude-3-5-sonnet-20241022, claude-3-5-sonnet-20240620, claude-3-opus-20240229, claude-3-sonnet-20240229, claude-3-5-haiku-20241022, claude-3-haiku-20240307, claude-2.1, claude-2.0, claude-instant-1.2
- Google Vertex AI: gemini-2.5-pro-exp-03-25, gemini-2.0-pro-exp-02-05, gemini-2.0-flash-001, gemini-2.0-flash-lite-preview-02-05, gemini-2.0-flash-exp, gemini-1.5-pro, gemini-1.5-flash, gemini-1.0-pro。你也可以在 LLM API Key 创建表单的 `Custom model names` 部分添加 Google Vertex AI 平台支持、且在你的 GCP 账户中已启用的其他模型名称。
- Google AI Studio: gemini-2.5-pro-exp-03-25, gemini-2.0-flash, gemini-2.0-flash-lite-preview-02-05, gemini-2.0-flash-thinking-exp-01-21, gemini-1.5-pro, gemini-1.5-flash, gemini-1.5-flash-8b
- Amazon Bedrock: 支持所有 Amazon Bedrock 模型。在 AWS 上需要的权限为 `bedrock:InvokeModel` 与 `bedrock:InvokeModelWithResponseStream`。
如果第三方 LLM 提供商的 API schema 实现了我们已支持的某个 provider adapter 的 schema,你也可以连接它。例如,可以通过 Litefuse 中的 OpenAI adapter 连接 Mistral 兼容 OpenAI 的 API。
高级配置
额外的 provider 选项
Provider 选项不在 Project Settings > LLM Connections 页面中配置,而是在 Playground 中选择 LLM Connection 时,或在配置 LLM-as-a-Judge 评估器时设置。
通过已创建的 LLM 连接发起的 LLM 调用,可以使用一组特定参数进行配置,例如 temperature、top_p 和 max_tokens。
但是许多 LLM 提供商在调用模型时还允许使用额外的参数,如 reasoning_effort、service_tier 等。这些参数在不同提供商之间通常各不相同。
你可以通过 JSON 对象为所有 LLM 调用提供额外配置。在模型参数设置中,最下方有一个 “provider options” 字段,可以在其中输入 LLM 提供商 API endpoint 接受的特定 key-value。
请参阅你所使用提供商的 API 参考,了解支持哪些额外字段:
- Anthropic Messages API Reference
- OpenAI Chat Completions API Reference
- Google Gemini API Reference
- Google Vertex AI Gemini API Reference
该功能目前对以下 adapter 可用:
- Anthropic
- OpenAI
- Google AI Studio
- Google Vertex AI
- AWS (Amazon Bedrock)
下面示例展示了在 OpenAI gpt-5 调用中强制设置 reasoning effort 为 minimal:

下面是 Google 模型(Google AI Studio 与 Google Vertex AI)用于控制思考过程的 provider 选项示例:
{
"thinkingLevel": "MEDIUM",
"thinkingBudget": 2048
}thinkingLevel 控制推理深度,thinkingBudget 设置思考使用的 token 预算。这些选项仅对支持思考能力的 Google 模型有效。
通过 gateway 连接
如果你通过兼容 OpenAI 的 gateway(例如 LiteLLM、OpenRouter 或 Portkey)路由 LLM 调用,可以将其作为 Playground 与 LLM-as-a-Judge 评估的 LLM 连接。
配置步骤:
- 进入 Project Settings > LLM Connections,点击 Add new LLM API key。
- 选择 OpenAI 作为 provider。
- 输入你的 gateway 的 API Key。
- 在 Advanced Settings 中,把 Base URL 设置为你的 gateway endpoint,例如
https://your-litellm-instance.com/v1。 - 添加你的 gateway 暴露的所有 custom model names。
Gateway 必须支持 OpenAI 格式的 tool calling,LLM-as-a-Judge 评估才能正常工作。
对于兼容 OpenAI 的 gateway,下面是一个 tool calling 请求示例,gateway 必须能够处理它,才能在 Litefuse 中支持 LLM-as-a-Judge:
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."
}
]
}'