diff --git a/README.md b/README.md index c92a66a9c..1bebbce1c 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ The cost: the model sees `{{API_KEY_…}}`, not the key, so a task about the val Pick a preset, paste a key. Model lists come from the vendor, with names and reasoning levels filled in from [models.dev](https://models.dev), so a model released this morning is in your picker on the next refresh. -> **Presets include** Anthropic · OpenAI · Google Gemini · Google Vertex AI · Amazon Bedrock (runtime and Mantle) · DeepSeek · Kimi · Zhipu GLM · MiniMax · StepFun · LongCat · Qwen · Baidu Qianfan · Tencent Cloud · Huawei Cloud MaaS · Volcengine Ark · Mistral · Voyage AI · Groq · Nous Portal · xAI · OpenRouter · Vercel AI Gateway · Together · Fireworks · SiliconFlow · NVIDIA NIM · ModelScope · Ollama · LM Studio … and any OpenAI- or Anthropic-compatible URL. +> **Presets include** Anthropic · OpenAI · Google Gemini · Google Vertex AI · Amazon Bedrock (runtime and Mantle) · DeepSeek · Kimi · Zhipu GLM · MiniMax · StepFun · LongCat · Qwen · Baidu Qianfan · Tencent Cloud · Huawei Cloud MaaS · Volcengine Ark · Mistral · Voyage AI · Groq · Nous Portal · xAI · OpenRouter · Vercel AI Gateway · Together · Fireworks · Fireworks Nexus · SiliconFlow · NVIDIA NIM · ModelScope · Ollama · LM Studio … and any OpenAI- or Anthropic-compatible URL. **Import** brings in the providers from CC Switch, Claude Code, Codex and Alma. **[Add to magpie](https://usemagpie.ai/docs/import)** links let a provider's website hand its config to magpie in one click. Each key and each account can go through a proxy of its own. diff --git a/README.zh-CN.md b/README.zh-CN.md index 6b2a969af..d37264105 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -152,7 +152,7 @@ Agent 会把读到的东西放进提示词:一个 `.env`、一份配置、一 选一个预设,粘贴 key。模型列表直接来自厂商,名称和推理档位从 [models.dev](https://models.dev) 补全,今天早上刚发布的模型,下次刷新就出现在你的选择器里。 -> **预设包括** Anthropic · OpenAI · Google Gemini · Amazon Bedrock(runtime 与 Mantle)· DeepSeek · Kimi · 智谱 GLM · MiniMax · 阶跃星辰 · LongCat · 通义千问 · 百度千帆 · 腾讯云 · 华为云 MaaS · 火山方舟 · Mistral · Voyage AI · Groq · Nous Portal · xAI · OpenRouter · Vercel AI Gateway · Together · Fireworks · 硅基流动 · NVIDIA NIM · 魔搭 · Ollama · LM Studio …… 以及任何兼容 OpenAI 或 Anthropic 的地址。 +> **预设包括** Anthropic · OpenAI · Google Gemini · Amazon Bedrock(runtime 与 Mantle)· DeepSeek · Kimi · 智谱 GLM · MiniMax · 阶跃星辰 · LongCat · 通义千问 · 百度千帆 · 腾讯云 · 华为云 MaaS · 火山方舟 · Mistral · Voyage AI · Groq · Nous Portal · xAI · OpenRouter · Vercel AI Gateway · Together · Fireworks · Fireworks Nexus · 硅基流动 · NVIDIA NIM · 魔搭 · Ollama · LM Studio …… 以及任何兼容 OpenAI 或 Anthropic 的地址。 **导入**能读取你在 CC Switch、Claude Code、Codex 和 Alma 里配置的 provider。[**「添加到 magpie」链接**](https://usemagpie.ai/docs/zh/import)让 provider 网站一键把配置交给 magpie。每个 key 和每个账号都可以走自己的代理。 diff --git a/docs/reference.md b/docs/reference.md index f125e0538..aca8ecead 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -56,7 +56,7 @@ line; agents connected to magpie lose it when it quits. - **Providers with one field.** Pick a preset (Anthropic, OpenAI, Gemini, Amazon Bedrock and its Mantle endpoint, DeepSeek, Kimi, GLM, MiniMax, StepFun, LongCat, Qwen, Baidu Qianfan, Tencent Cloud Token Plan, Huawei Cloud MaaS, Volcengine Ark, Mistral, Groq, Nous Portal, xAI, OpenRouter, Together, - Fireworks, SiliconFlow, NVIDIA NIM, ModelScope, AiHubMix, PipeLLM, 302.AI, Ollama, LM Studio…), + Fireworks, Fireworks Nexus, SiliconFlow, NVIDIA NIM, ModelScope, AiHubMix, PipeLLM, 302.AI, Ollama, LM Studio…), paste a key, done. Custom vendors need a name and a base URL. magpie never reads keys from your shell environment. - **Real model lists, nothing compiled in.** With a key in hand magpie asks diff --git a/internal/provider/fireworks_nexus_test.go b/internal/provider/fireworks_nexus_test.go new file mode 100644 index 000000000..aef16bf42 --- /dev/null +++ b/internal/provider/fireworks_nexus_test.go @@ -0,0 +1,55 @@ +package provider + +import ( + "net/http" + "net/http/httptest" + "slices" + "testing" +) + +// Fireworks Nexus (CNSA0422 on X) is the platform's /inference API with a +// key from nexus.fireworks.ai, on all three APIs. Pro and Team refuse every +// model but `auto` (docs.fireworks.ai/nexus/open-models: 403), so `auto` is +// its list, and no list is asked for: the platform's would offer models the +// plan refuses. +func TestFireworksNexusPreset(t *testing.T) { + detectHome(t) + p, err := FromPreset("fireworks-nexus") + if err != nil { + t.Fatal(err) + } + if p.Chat != "https://api.fireworks.ai/inference/v1" || p.Responses != "https://api.fireworks.ai/inference/v1" || + p.Anthropic != "https://api.fireworks.ai/inference" { + t.Fatalf("endpoints %q %q %q", p.Chat, p.Responses, p.Anthropic) + } + if p.KeysURL != "https://nexus.fireworks.ai/settings/api-keys" { + t.Fatalf("keys at %q", p.KeysURL) + } + if pr := Preset("fireworks-nexus"); !slices.Equal(pr.HeaderHints, []string{"x-anthropic-api-key", "x-openai-api-key"}) { + t.Fatalf("header hints %v", pr.HeaderHints) + } + asked := false + up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + asked = true + w.Header().Set("Content-Type", "application/json") + w.Write([]byte(`{"object":"list","data":[{"id":"accounts/fireworks/models/glm-5p3","object":"model"}]}`)) + })) + defer up.Close() + p.Key = "fw_test" + p.Chat, p.Responses, p.Anthropic = up.URL+"/inference/v1", up.URL+"/inference/v1", up.URL+"/inference" + for name, list := range map[string]func() ([]string, error){ + "fetch": func() ([]string, error) { ms, err := p.fetch(t.Context()); return modelIDs(ms), err }, + "all": func() ([]string, error) { ms, err := p.ListAll(t.Context()); return modelIDs(ms), err }, + } { + got, err := list() + if err != nil { + t.Fatalf("%s: %v", name, err) + } + if !slices.Equal(got, []string{"auto"}) { + t.Fatalf("%s: models %v", name, got) + } + } + if asked { + t.Fatal("the platform's /models was asked") + } +} diff --git a/internal/provider/presets.go b/internal/provider/presets.go index a9ec8bddd..3b2c169c2 100644 --- a/internal/provider/presets.go +++ b/internal/provider/presets.go @@ -602,6 +602,22 @@ var presets = []PresetDef{ {ID: "fireworks", Name: "Fireworks", Icon: "fireworks-color", Kind: KindRelay, Catalog: "fireworks-ai", Chat: "https://api.fireworks.ai/inference/v1", Website: "https://fireworks.ai", KeysURL: "https://app.fireworks.ai/settings/users/api-keys"}, + // Fireworks Nexus (CNSA0422 on X): an account and plan of its own at + // nexus.fireworks.ai, with keys made there, on the platform's + // /inference endpoints, which speak chat completions, Responses and + // messages alike (docs.fireworks.ai/nexus/apis-and-sdks). Pro and Team + // take only `auto`, Nexus Auto, and refuse an open model named directly + // with a 403 (nexus/open-models), so `auto` is the list; an Enterprise + // account's open models are typed in. Nexus Auto reaches Claude and GPT + // with the user's own keys in the two headers, or with Provider Keys + // set up on the account. + {ID: "fireworks-nexus", Name: "Fireworks Nexus", Short: "Nexus", Icon: "fireworks-color", Kind: KindRelay, + Chat: "https://api.fireworks.ai/inference/v1", Responses: "https://api.fireworks.ai/inference/v1", Anthropic: "https://api.fireworks.ai/inference", + Note: "Nexus Auto · Pro, Team, Enterprise", + Website: "https://docs.fireworks.ai/nexus", KeysURL: "https://nexus.fireworks.ai/settings/api-keys", + NoList: true, + Models: []string{"auto"}, + HeaderHints: []string{"x-anthropic-api-key", "x-openai-api-key"}}, {ID: "siliconflow", Name: "SiliconFlow", Icon: "siliconcloud-color", Kind: KindRelay, Catalog: "siliconflow", Chat: "https://api.siliconflow.cn/v1", Website: "https://cloud.siliconflow.cn", KeysURL: "https://cloud.siliconflow.cn/account/ak",