Skip to content

Commit a0b49d5

Browse files
authored
feat(llm): add iFlytek Spark as a built-in provider (#485)
Spark's official endpoint (https://spark-api-open.xf-yun.com/v1) is OpenAI-compatible, so it registers like the other OpenAI-protocol providers (deepseek, kimi, …). Adds the registry entry, the matching name in the provider-order test, and the provider table in the en/zh/ja configuration docs. Model ids are the domain values the HTTP endpoint accepts (4.0Ultra, generalv3.5, max-32k, generalv3, pro-128k, lite). Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
1 parent 6ae397b commit a0b49d5

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

internal/llm/providers.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ var registry = []Provider{
168168
"hy3-preview",
169169
},
170170
},
171+
{
172+
Name: "iflytek",
173+
DisplayName: "iFlytek Spark API",
174+
Protocol: ProtocolOpenAIChatCompletions,
175+
BaseURL: "https://spark-api-open.xf-yun.com/v1",
176+
EnvVar: "SPARK_API_KEY",
177+
Models: []string{
178+
"4.0Ultra",
179+
"generalv3.5",
180+
"max-32k",
181+
"generalv3",
182+
"pro-128k",
183+
"lite",
184+
},
185+
},
171186
{
172187
Name: "kimi",
173188
DisplayName: "Kimi Moonshot API",

internal/llm/providers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestListProviders_Order(t *testing.T) {
4040
if len(providers) < 3 {
4141
t.Fatalf("expected at least 3 providers, got %d", len(providers))
4242
}
43-
expected := []string{"anthropic", "baidu-qianfan", "dashscope", "dashscope-tokenplan", "deepseek", "edenai", "hy-tokenplan", "kimi", "litellm", "mimo", "minimax", "ollama-cloud", "openai", "tencent-tokenhub", "volcengine", "z-ai", "z-ai-coding"}
43+
expected := []string{"anthropic", "baidu-qianfan", "dashscope", "dashscope-tokenplan", "deepseek", "edenai", "hy-tokenplan", "iflytek", "kimi", "litellm", "mimo", "minimax", "ollama-cloud", "openai", "tencent-tokenhub", "volcengine", "z-ai", "z-ai-coding"}
4444
if len(providers) != len(expected) {
4545
t.Fatalf("expected %d providers, got %d", len(expected), len(providers))
4646
}

pages/src/content/docs/en/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ environment variable.
5252
| `deepseek` | openai | `https://api.deepseek.com` | `DEEPSEEK_API_KEY` |
5353
| `tencent-tokenhub` | openai | `https://tokenhub.tencentmaas.com/v1` | `TENCENT_TOKENHUB_API_KEY` |
5454
| `hy-tokenplan` | openai | `https://api.lkeap.cloud.tencent.com/plan/v3` | `TENCENT_HUNYUAN_TOKENPLAN_KEY` |
55+
| `iflytek` | openai | `https://spark-api-open.xf-yun.com/v1` | `SPARK_API_KEY` |
5556
| `kimi` | openai | `https://api.moonshot.cn/v1` | `MOONSHOT_API_KEY` |
5657
| `z-ai` | openai | `https://open.bigmodel.cn/api/paas/v4` | `Z_AI_API_KEY` |
5758
| `mimo` | openai | `https://api.xiaomimimo.com/v1` | `MIMO_API_KEY` |

pages/src/content/docs/ja/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ocr config set providers.anthropic.api_key sk-ant-xxxxxxxxxx
5050
| `deepseek` | openai | `https://api.deepseek.com` | `DEEPSEEK_API_KEY` |
5151
| `tencent-tokenhub` | openai | `https://tokenhub.tencentmaas.com/v1` | `TENCENT_TOKENHUB_API_KEY` |
5252
| `hy-tokenplan` | openai | `https://api.lkeap.cloud.tencent.com/plan/v3` | `TENCENT_HUNYUAN_TOKENPLAN_KEY` |
53+
| `iflytek` | openai | `https://spark-api-open.xf-yun.com/v1` | `SPARK_API_KEY` |
5354
| `kimi` | openai | `https://api.moonshot.cn/v1` | `MOONSHOT_API_KEY` |
5455
| `z-ai` | openai | `https://open.bigmodel.cn/api/paas/v4` | `Z_AI_API_KEY` |
5556
| `mimo` | openai | `https://api.xiaomimimo.com/v1` | `MIMO_API_KEY` |

pages/src/content/docs/zh/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ocr config set providers.anthropic.api_key sk-ant-xxxxxxxxxx
4949
| `deepseek` | openai | `https://api.deepseek.com` | `DEEPSEEK_API_KEY` |
5050
| `tencent-tokenhub` | openai | `https://tokenhub.tencentmaas.com/v1` | `TENCENT_TOKENHUB_API_KEY` |
5151
| `hy-tokenplan` | openai | `https://api.lkeap.cloud.tencent.com/plan/v3` | `TENCENT_HUNYUAN_TOKENPLAN_KEY` |
52+
| `iflytek` | openai | `https://spark-api-open.xf-yun.com/v1` | `SPARK_API_KEY` |
5253
| `kimi` | openai | `https://api.moonshot.cn/v1` | `MOONSHOT_API_KEY` |
5354
| `z-ai` | openai | `https://open.bigmodel.cn/api/paas/v4` | `Z_AI_API_KEY` |
5455
| `mimo` | openai | `https://api.xiaomimimo.com/v1` | `MIMO_API_KEY` |

0 commit comments

Comments
 (0)