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
12 changes: 12 additions & 0 deletions internal/llm/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ var registry = []Provider{
"deepseek/deepseek-v4-flash-0731",
},
},
{
Name: "xai",
DisplayName: "xAI Grok API",
Protocol: ProtocolOpenAIChatCompletions,
BaseURL: "https://api.x.ai/v1",
EnvVar: "XAI_API_KEY",
Models: []string{
"grok-4.6",
"grok-4.5",
"grok-4.3",
},
Comment thread
Magixyne marked this conversation as resolved.
},
{
Name: "litellm",
DisplayName: "LiteLLM AI Gateway",
Expand Down
37 changes: 36 additions & 1 deletion internal/llm/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestListProviders_Order(t *testing.T) {
if len(providers) < 3 {
t.Fatalf("expected at least 3 providers, got %d", len(providers))
}
expected := []string{"anthropic", "baidu-qianfan", "dashscope", "dashscope-tokenplan", "deepseek", "edenai", "hy-tokenplan", "iflytek", "kimi", "litellm", "mimo", "minimax", "minimax-cn", "mistral", "novita", "ollama-cloud", "openai", "siliconflow", "siliconflow-cn", "tencent-tokenhub", "volcengine", "z-ai", "z-ai-coding"}
expected := []string{"anthropic", "baidu-qianfan", "dashscope", "dashscope-tokenplan", "deepseek", "edenai", "hy-tokenplan", "iflytek", "kimi", "litellm", "mimo", "minimax", "minimax-cn", "mistral", "novita", "ollama-cloud", "openai", "siliconflow", "siliconflow-cn", "tencent-tokenhub", "volcengine", "xai", "z-ai", "z-ai-coding"}
if len(providers) != len(expected) {
t.Fatalf("expected %d providers, got %d", len(expected), len(providers))
}
Expand Down Expand Up @@ -314,6 +314,41 @@ func TestLookupProvider_MistralDetails(t *testing.T) {
}
}

func TestLookupProvider_XAIDetails(t *testing.T) {
p, ok := LookupProvider("xai")
if !ok {
t.Fatal("xai not found")
}
if p.DisplayName != "xAI Grok API" {
t.Errorf("DisplayName = %q, want %q", p.DisplayName, "xAI Grok API")
}
if p.Protocol != ProtocolOpenAIChatCompletions {
t.Errorf("Protocol = %q, want %q", p.Protocol, ProtocolOpenAIChatCompletions)
}
if p.BaseURL != "https://api.x.ai/v1" {
t.Errorf("BaseURL = %q, want %q", p.BaseURL, "https://api.x.ai/v1")
}
if p.EnvVar != "XAI_API_KEY" {
t.Errorf("EnvVar = %q, want %q", p.EnvVar, "XAI_API_KEY")
}
if p.AuthHeader != "" {
t.Errorf("AuthHeader = %q, want empty (OpenAI-compatible uses Bearer by default)", p.AuthHeader)
}
expectedModels := []string{
"grok-4.6",
"grok-4.5",
"grok-4.3",
}
if len(p.Models) != len(expectedModels) {
t.Fatalf("Models length = %d, want %d", len(p.Models), len(expectedModels))
}
for i, model := range expectedModels {
if p.Models[i] != model {
t.Errorf("Models[%d] = %q, want %q", i, p.Models[i], model)
}
}
}

// TestProviders_AllProtocolsCanonical verifies every registry entry uses a
// canonical protocol constant — no stale "openai" / "anthropic" literals that
// would bypass NormalizeProtocol downstream.
Expand Down
1 change: 1 addition & 0 deletions pages/src/content/docs/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ environment variable.
| `siliconflow` | openai | `https://api.siliconflow.com/v1` | `SILICONFLOW_GLOBAL_API_KEY` |
| `siliconflow-cn` | openai | `https://api.siliconflow.cn/v1` | `SILICONFLOW_API_KEY` |
| `novita` | openai | `https://api.novita.ai/openai` | `NOVITA_API_KEY` |
| `xai` | openai | `https://api.x.ai/v1` | `XAI_API_KEY` |

### Custom providers

Expand Down
1 change: 1 addition & 0 deletions pages/src/content/docs/ja/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ocr config set providers.anthropic.api_key sk-ant-xxxxxxxxxx
| `siliconflow` | openai | `https://api.siliconflow.com/v1` | `SILICONFLOW_GLOBAL_API_KEY` |
| `siliconflow-cn` | openai | `https://api.siliconflow.cn/v1` | `SILICONFLOW_API_KEY` |
| `novita` | openai | `https://api.novita.ai/openai` | `NOVITA_API_KEY` |
| `xai` | openai | `https://api.x.ai/v1` | `XAI_API_KEY` |

### カスタム provider

Expand Down
1 change: 1 addition & 0 deletions pages/src/content/docs/ru/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ API-ключ. Если `providers.<name>.api_key` не задан, OCR испо
| `siliconflow` | openai | `https://api.siliconflow.com/v1` | `SILICONFLOW_GLOBAL_API_KEY` |
| `siliconflow-cn` | openai | `https://api.siliconflow.cn/v1` | `SILICONFLOW_API_KEY` |
| `novita` | openai | `https://api.novita.ai/openai` | `NOVITA_API_KEY` |
| `xai` | openai | `https://api.x.ai/v1` | `XAI_API_KEY` |

### Пользовательские провайдеры

Expand Down
1 change: 1 addition & 0 deletions pages/src/content/docs/zh/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ocr config set providers.anthropic.api_key sk-ant-xxxxxxxxxx
| `siliconflow` | openai | `https://api.siliconflow.com/v1` | `SILICONFLOW_GLOBAL_API_KEY` |
| `siliconflow-cn` | openai | `https://api.siliconflow.cn/v1` | `SILICONFLOW_API_KEY` |
| `novita` | openai | `https://api.novita.ai/openai` | `NOVITA_API_KEY` |
| `xai` | openai | `https://api.x.ai/v1` | `XAI_API_KEY` |

### 自定义 provider

Expand Down
Loading