| 1 | /** |
| 2 | * The AI providers a workspace can keep credentials for, as its AI page |
| 3 | * shows them: grouped (frontier labs and model platforms, then models it |
| 4 | * hosts itself), with a line each, a mark, and where to get a key. |
| 5 | */ |
| 6 | import { type AiGroup, type AiProvider, AI_PROVIDERS } from "@g1t/contracts/ai"; |
| 7 | |
| 8 | /** How the AI page shows a provider; its name, group and API are the contracts' `AI_PROVIDERS`. */ |
| 9 | export type AiProviderLook = { |
| 10 | blurb: string; |
| 11 | /** The provider's colour, for its mark. */ |
| 12 | color: string; |
| 13 | /** What the mark shows: an initial or two. Empty for an icon. */ |
| 14 | mark: string; |
| 15 | /** Where to get a key. */ |
| 16 | keyUrl?: string; |
| 17 | keyPlaceholder?: string; |
| 18 | /** A model to suggest. */ |
| 19 | model?: string; |
| 20 | }; |
| 21 | |
| 22 | /** How each AI provider is shown. */ |
| 23 | export const AI_PROVIDER_LOOKS: Record<AiProvider, AiProviderLook> = { |
| 24 | anthropic: { |
| 25 | blurb: "Claude, on your own Anthropic key.", |
| 26 | color: "#d97757", |
| 27 | mark: "A", |
| 28 | keyUrl: "https://console.anthropic.com/settings/keys", |
| 29 | keyPlaceholder: "sk-ant-…", |
| 30 | }, |
| 31 | openai: { |
| 32 | blurb: "GPT and the o-series, on your own OpenAI key.", |
| 33 | color: "#10a37f", |
| 34 | mark: "O", |
| 35 | keyUrl: "https://platform.openai.com/api-keys", |
| 36 | keyPlaceholder: "sk-…", |
| 37 | model: "gpt-5", |
| 38 | }, |
| 39 | gemini: { |
| 40 | blurb: "Gemini, on your own Google AI Studio key.", |
| 41 | color: "#4285f4", |
| 42 | mark: "G", |
| 43 | keyUrl: "https://aistudio.google.com/apikey", |
| 44 | model: "gemini-2.5-pro", |
| 45 | }, |
| 46 | xai: { |
| 47 | blurb: "Grok, on your own xAI key.", |
| 48 | color: "#e5e5e5", |
| 49 | mark: "x", |
| 50 | keyUrl: "https://console.x.ai", |
| 51 | keyPlaceholder: "xai-…", |
| 52 | model: "grok-4", |
| 53 | }, |
| 54 | mistral: { |
| 55 | blurb: "Mistral and Codestral, on your own key.", |
| 56 | color: "#fa520f", |
| 57 | mark: "M", |
| 58 | keyUrl: "https://console.mistral.ai/api-keys", |
| 59 | model: "mistral-large-latest", |
| 60 | }, |
| 61 | deepseek: { |
| 62 | blurb: "DeepSeek's chat and reasoning models.", |
| 63 | color: "#4d6bfe", |
| 64 | mark: "D", |
| 65 | keyUrl: "https://platform.deepseek.com/api_keys", |
| 66 | keyPlaceholder: "sk-…", |
| 67 | model: "deepseek-chat", |
| 68 | }, |
| 69 | azure_openai: { |
| 70 | blurb: "OpenAI's models on your own Azure resource and contract.", |
| 71 | color: "#0078d4", |
| 72 | mark: "Az", |
| 73 | }, |
| 74 | openrouter: { |
| 75 | blurb: "Hundreds of models from every lab, on one key.", |
| 76 | color: "#7c7ff5", |
| 77 | mark: "OR", |
| 78 | keyUrl: "https://openrouter.ai/keys", |
| 79 | keyPlaceholder: "sk-or-…", |
| 80 | model: "anthropic/claude-sonnet-4.5", |
| 81 | }, |
| 82 | groq: { |
| 83 | blurb: "Open models at very high speed.", |
| 84 | color: "#f55036", |
| 85 | mark: "Gq", |
| 86 | keyUrl: "https://console.groq.com/keys", |
| 87 | keyPlaceholder: "gsk_…", |
| 88 | model: "moonshotai/kimi-k2-instruct", |
| 89 | }, |
| 90 | together: { |
| 91 | blurb: "Open models: Llama, Qwen, DeepSeek, Kimi.", |
| 92 | color: "#0f6fff", |
| 93 | mark: "T", |
| 94 | keyUrl: "https://api.together.ai/settings/api-keys", |
| 95 | model: "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8", |
| 96 | }, |
| 97 | fireworks: { |
| 98 | blurb: "Fast open models, and your own fine-tunes.", |
| 99 | color: "#7c3aed", |
| 100 | mark: "F", |
| 101 | keyUrl: "https://fireworks.ai/account/api-keys", |
| 102 | model: "accounts/fireworks/models/kimi-k2-instruct", |
| 103 | }, |
| 104 | cerebras: { |
| 105 | blurb: "Open models on wafer-scale chips.", |
| 106 | color: "#f05a28", |
| 107 | mark: "C", |
| 108 | keyUrl: "https://cloud.cerebras.ai", |
| 109 | keyPlaceholder: "csk-…", |
| 110 | model: "qwen-3-coder-480b", |
| 111 | }, |
| 112 | anthropic_endpoint: { |
| 113 | blurb: "Anything that speaks Anthropic's API: your own gateway, LiteLLM, Bedrock or Vertex behind a proxy.", |
| 114 | color: "#a1a1aa", |
| 115 | mark: "", |
| 116 | }, |
| 117 | openai_endpoint: { |
| 118 | blurb: "Anything that speaks OpenAI's API: vLLM, Ollama behind a tunnel, LiteLLM, a gateway.", |
| 119 | color: "#a1a1aa", |
| 120 | mark: "", |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | /** The groups, in the order people are shown them. */ |
| 125 | export const AI_PROVIDER_GROUPS: { group: AiGroup; title: string }[] = [ |
| 126 | { group: "labs", title: "Frontier labs" }, |
| 127 | { group: "platforms", title: "Model platforms" }, |
| 128 | { group: "self_hosted", title: "Self-hosted or your own gateway" }, |
| 129 | ]; |
| 130 | |
| 131 | /** The AI providers in one group, in catalogue order. */ |
| 132 | export function aiProvidersIn(group: AiGroup): AiProvider[] { |
| 133 | return (Object.keys(AI_PROVIDERS) as AiProvider[]).filter((provider) => AI_PROVIDERS[provider].group === group); |
| 134 | } |
| 135 | |
| 136 | /** Whether a provider is one whose own endpoint the workspace gives. */ |
| 137 | export function isEndpoint(provider: AiProvider): boolean { |
| 138 | return AI_PROVIDERS[provider].group === "self_hosted"; |
| 139 | } |