v0.10.5

自訂端點

最後更新


如何把 router 指向自架或第三方 OpenAI 相容端點,或 Cloudflare Workers AI。

自架與第三方相容端點


  1. // 明確指定實例名,Name() 會回 lmstudio@qwen3-30b
  2. agent, err := router.New(router.Config{
  3. Name: "compat[lmstudio]@qwen3-30b",
  4. BaseURL: "http://127.0.0.1:1234/v1",
  5. APIKey: "not-needed",
  6. })
  7. // 未知前綴自動落到 compat,Name() 保留原前綴
  8. agent, err = router.New(router.Config{
  9. Name: "groq@llama-3.3-70b",
  10. BaseURL: "https://api.groq.com/openai/v1",
  11. APIKey: os.Getenv("GROQ_API_KEY"),
  12. })

Cloudflare Workers AI


  1. agent, err := router.New(router.Config{
  2. Name: "cloudflare@@cf/meta/llama-3.3-70b-instruct-fp8-fast",
  3. APIKey: os.Getenv("CLOUDFLARE_API_KEY"),
  4. AccountID: os.Getenv("CLOUDFLARE_ACCOUNT_ID"),
  5. GatewayID: os.Getenv("CLOUDFLARE_GATEWAY_ID"),
  6. })

模型清單以 Workers AI 的 task 名稱篩選,而非模型 ID 標記,因此 ModelFilter{STTOnly: true} 會取 Automatic Speech Recognition 這個 task。

相關頁面


EN