| 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 | /** How to get one there, in a sentence or two, for someone who never has. */ |
| 18 | keyHow?: string; |
| 19 | keyPlaceholder?: string; |
| 20 | /** A model to suggest. */ |
| 21 | model?: string; |
| 22 | }; |
| 23 | |
| 24 | /** How each AI provider is shown. */ |
| 25 | export const AI_PROVIDER_LOOKS: Record<AiProvider, AiProviderLook> = { |
| 26 | anthropic: { |
| 27 | blurb: "Claude, on your own Anthropic key.", |
| 28 | color: "#d97757", |
| 29 | mark: "A", |
| 30 | keyUrl: "https://platform.claude.com/settings/keys", |
| 31 | keyPlaceholder: "sk-ant-…", |
| 32 | keyHow: "Sign in to the Claude Console, choose Create key and copy it. The account needs credits under Billing; a Claude.ai subscription does not include the API.", |
| 33 | }, |
| 34 | openai: { |
| 35 | blurb: "GPT and the o-series, on your own OpenAI key.", |
| 36 | color: "#10a37f", |
| 37 | mark: "O", |
| 38 | keyUrl: "https://platform.openai.com/api-keys", |
| 39 | keyPlaceholder: "sk-…", |
| 40 | model: "gpt-5", |
| 41 | keyHow: "Choose Create new secret key and copy it. The API needs credit under Settings → Billing; a ChatGPT subscription does not include it.", |
| 42 | }, |
| 43 | gemini: { |
| 44 | blurb: "Gemini, on your own Google AI Studio key.", |
| 45 | color: "#4285f4", |
| 46 | mark: "G", |
| 47 | keyUrl: "https://aistudio.google.com/apikey", |
| 48 | model: "gemini-2.5-pro", |
| 49 | keyHow: "Sign in with a Google account, choose Create API key and copy it. The free tier needs no card.", |
| 50 | }, |
| 51 | xai: { |
| 52 | blurb: "Grok, on your own xAI key.", |
| 53 | color: "#e5e5e5", |
| 54 | mark: "x", |
| 55 | keyUrl: "https://console.x.ai", |
| 56 | keyPlaceholder: "xai-…", |
| 57 | model: "grok-4", |
| 58 | keyHow: "Open API Keys, choose Create API key and copy it. The team needs credits under Billing.", |
| 59 | }, |
| 60 | mistral: { |
| 61 | blurb: "Mistral and Codestral, on your own key.", |
| 62 | color: "#fa520f", |
| 63 | mark: "M", |
| 64 | keyUrl: "https://console.mistral.ai/api-keys", |
| 65 | model: "mistral-large-latest", |
| 66 | keyHow: "Choose Create new key and copy it. The workspace needs a plan under Billing; the free Experiment plan works.", |
| 67 | }, |
| 68 | deepseek: { |
| 69 | blurb: "DeepSeek's chat and reasoning models.", |
| 70 | color: "#4d6bfe", |
| 71 | mark: "D", |
| 72 | keyUrl: "https://platform.deepseek.com/api_keys", |
| 73 | keyPlaceholder: "sk-…", |
| 74 | model: "deepseek-chat", |
| 75 | keyHow: "Choose Create new API key and copy it. The account needs a balance under Top up.", |
| 76 | }, |
| 77 | azure_openai: { |
| 78 | blurb: "OpenAI's models on your own Azure resource and contract.", |
| 79 | color: "#0078d4", |
| 80 | mark: "Az", |
| 81 | keyUrl: "https://portal.azure.com", |
| 82 | keyHow: "Open your Azure OpenAI resource, then Resource Management → Keys and Endpoint: copy KEY 1 and the endpoint. Deployments are listed in the Azure AI Foundry portal.", |
| 83 | }, |
| 84 | openrouter: { |
| 85 | blurb: "Hundreds of models from every lab, on one key.", |
| 86 | color: "#7c7ff5", |
| 87 | mark: "OR", |
| 88 | keyUrl: "https://openrouter.ai/keys", |
| 89 | keyPlaceholder: "sk-or-…", |
| 90 | model: "anthropic/claude-sonnet-4.5", |
| 91 | keyHow: "Choose Create Key and copy it. Paid models need credits under Credits.", |
| 92 | }, |
| 93 | groq: { |
| 94 | blurb: "Open models at very high speed.", |
| 95 | color: "#f55036", |
| 96 | mark: "Gq", |
| 97 | keyUrl: "https://console.groq.com/keys", |
| 98 | keyPlaceholder: "gsk_…", |
| 99 | model: "moonshotai/kimi-k2-instruct", |
| 100 | keyHow: "Choose Create API Key and copy it. The free tier needs no card.", |
| 101 | }, |
| 102 | together: { |
| 103 | blurb: "Open models: Llama, Qwen, DeepSeek, Kimi.", |
| 104 | color: "#0f6fff", |
| 105 | mark: "T", |
| 106 | keyUrl: "https://api.together.ai/settings/api-keys", |
| 107 | model: "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8", |
| 108 | keyHow: "Copy the key shown there, or create one.", |
| 109 | }, |
| 110 | fireworks: { |
| 111 | blurb: "Fast open models, and your own fine-tunes.", |
| 112 | color: "#7c3aed", |
| 113 | mark: "F", |
| 114 | keyUrl: "https://fireworks.ai/account/api-keys", |
| 115 | model: "accounts/fireworks/models/kimi-k2-instruct", |
| 116 | keyHow: "Choose Create API Key and copy it.", |
| 117 | }, |
| 118 | cerebras: { |
| 119 | blurb: "Open models on wafer-scale chips.", |
| 120 | color: "#f05a28", |
| 121 | mark: "C", |
| 122 | keyUrl: "https://cloud.cerebras.ai", |
| 123 | keyPlaceholder: "csk-…", |
| 124 | model: "qwen-3-coder-480b", |
| 125 | keyHow: "Open API Keys, choose Generate API Key and copy it.", |
| 126 | }, |
| 127 | anthropic_endpoint: { |
| 128 | blurb: "Anything that speaks Anthropic's API: your own gateway, LiteLLM, Bedrock or Vertex behind a proxy.", |
| 129 | color: "#a1a1aa", |
| 130 | mark: "", |
| 131 | }, |
| 132 | openai_endpoint: { |
| 133 | blurb: "Anything that speaks OpenAI's API: vLLM, Ollama behind a tunnel, LiteLLM, a gateway.", |
| 134 | color: "#a1a1aa", |
| 135 | mark: "", |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | /** The groups, in the order people are shown them. */ |
| 140 | export const AI_PROVIDER_GROUPS: { group: AiGroup; title: string }[] = [ |
| 141 | { group: "labs", title: "Frontier labs" }, |
| 142 | { group: "platforms", title: "Model platforms" }, |
| 143 | { group: "self_hosted", title: "Self-hosted or your own gateway" }, |
| 144 | ]; |
| 145 | |
| 146 | /** The AI providers in one group, in catalogue order. */ |
| 147 | export function aiProvidersIn(group: AiGroup): AiProvider[] { |
| 148 | return (Object.keys(AI_PROVIDERS) as AiProvider[]).filter((provider) => AI_PROVIDERS[provider].group === group); |
| 149 | } |
| 150 | |
| 151 | /** Whether a provider is one whose own endpoint the workspace gives. */ |
| 152 | export function isEndpoint(provider: AiProvider): boolean { |
| 153 | return AI_PROVIDERS[provider].group === "self_hosted"; |
| 154 | } |