November 16, 2026
How to Get an LLM API Key: A Complete Tutorial for Every Provider and Third-Party Integration
If you want to build with large language models β whether in your own code, an IDE assistant, or a no-code tool (like note app Obsidian orβ¦
By Askshanway
26 min read
If you want to build with large language models β whether in your own code, an IDE assistant, or a no-code tool (like note app Obsidian or OneNote plugin HydroMark) β the first step is always the same: get an API key. This tutorial walks you through every major first-party provider, the enterprise cloud platforms, the third-party aggregators that give you one key for many models, and how to plug those keys into popular tools and frameworks
1. What Is an API Key and How It Works
An API key is a secret token that does three jobs at once:
- ID card β it authenticates your application to the provider's server.
- Universal key β it unlocks the model you are calling.
- Credit card β every token you consume is billed to the account the key belongs to.
Mechanically, it is simple. Each request carries the key in an HTTP header (usually Authorization: Bearer <key>), the server validates it, checks your quota, runs the model, and logs usage against your balance. A wrong or exhausted key gets you 401 Unauthorized or 429 Rate Limit Exceeded.
Two facts matter before you start:
- Keys are shown only once. Almost every provider displays the full key a single time at creation. Copy it immediately into a password manager or
.envfile. - Billing is separate from signup. Most providers require a payment method or prepaid credits before the API works β even if the chat app itself is free.
2. First-Party Providers: International
2.1 OpenAI (GPT series)
- Console: https://platform.openai.com
- Steps:
- Create an account and verify your email/phone.
- Go to Settings β API Keys β Create new secret key. Choose a project and permissions (restricted keys are safer than full-access keys).
- Copy the key (
sk-proj-...) β it is shown once. - Go to Billing β Add payment method and buy credits (minimum ~$5). The API will return errors until billing is active.
- Notes: OpenAI uses a tier system (Free β Tier 5). Higher tiers, unlocked by deposits and usage history, raise rate limits and unlock newer models.
- Base URL: https://api.openai.com/v1
Official docs: OpenAI API docs
2.2 Anthropic (Claude series)
- Console: console.anthropic.com
- Steps:
- Sign up and verify your account.
- Go to Settings β API Keys β Create Key, give it a descriptive name (e.g.
myapp-production). - Copy the key (
sk-ant-...) β shown once. - Go to Billing and purchase prepaid credits, or set up postpaid billing once you have usage history.
- Notes: Claude models use the Messages API; SDKs exist for Python, TypeScript, Java, and Go.
- Base URL: https://api.anthropic.com
Official docs: Anthropic docs
2.3 Google (Gemini series)
Google offers two routes:
Route Audience Cost Google AI Studio (aistudio.google.com) Individual developers Has a genuinely free tier (rate-limited; free-tier data may be used for training) Vertex AI Enterprises on GCP Pay-as-you-go, no training on your data
- AI Studio steps (recommended for beginners):
- Visit aistudio.google.com/apikey and sign in with a Google account.
- Click Create API key β pick an existing Google Cloud project or let it create one.
- Copy the key (
AIza..., 39 characters). No credit card required to start.
- Notes: Keys starting with
AQ.Ab8...are OAuth tokens from the Gemini CLI, not API keys β they do not work for direct API calls. - Base URL: https://generativelanguage.googleapis.com
Official docs: Gemini API docs
2.4 xAI (Grok series)
- Console: console.x.ai
- Steps: Sign in with an X (Twitter) account β API Keys β Create key β copy immediately β add a payment method under Billing.
- Base URL:
https://api.x.ai/v1(OpenAI-compatible)
Official docs: xAI docs
2.5 Mistral AI
- Console: console.mistral.ai (La Plateforme / Studio)
- Steps: Create an account β choose a plan (a Free/Experiment mode exists with usage and rate limits, no credit card required) β API Keys β Create new key β set optional expiration β copy once.
- Base URL: https://api.mistral.ai/v1
Official docs: Mistral docs
2.6 Cohere
- Console: dashboard.cohere.com
- Steps: Sign up β API Keys β Create key. Trial keys are free with rate limits; production keys require billing.
- Base URL: https://api.cohere.com
Official docs: Cohere docs
2.7 DeepSeek (single global platform)
- Console: platform.deepseek.com
- Steps: Sign up β international users can register with email β API Keys β Create new API key β copy β Top Up with credits (from ~$2).
- Notes: Unlike other Chinese vendors, DeepSeek operates one official API platform serving both China and international users β there is no separate overseas console or endpoint. All official-API traffic runs on infrastructure in China; if that is a compliance concern, its open-weight models are also served on Western infrastructure via Together, Fireworks, DeepInfra, or OpenRouter.
- Base URL:
https://api.deepseek.com(OpenAI-compatible); Anthropic-compatible:https://api.deepseek.com/anthropicβ works with tools like Claude Code
Official docs: DeepSeek API docs
2.8 Alibaba Qwen β Model Studio International (DashScope Intl)
- Console: Alibaba Cloud International account β Model Studio (a separate Alibaba account from the China one)
- Steps: Sign up at the Alibaba Cloud international site β open Model Studio β API-KEY management β Create β copy.
- Base URL:
https://dashscope-intl.aliyuncs.com/compatible-mode/v1(OpenAI-compatible)
Official docs: Alibaba Cloud Model Studio Intl docs
2.9 ByteDance β BytePlus ModelArk (Doubao / Seed models)
- Console: console.bytepluses.com (BytePlus is ByteDance's overseas brand; separate account from Volcano Engine)
- Steps: Sign up β open ModelArk β enable a model endpoint β generate an API key.
- Base URL:
https://ark.ap-southeast.bytepluses.com/api/v3(OpenAI-compatible)
Official docs: BytePlus ModelArk docs
2.10 Moonshot AI β Kimi International
- Console: platform.moonshot.ai (separate account from platform.moonshot.cn; USD billing)
- Steps: Sign up β API Keys β Create β copy β top up in USD.
- Base URL:
https://api.moonshot.ai/v1(OpenAI-compatible); Anthropic-compatible: https://api.moonshot.ai/anthropic
Official docs: Kimi international API docs
2.11 Zhipu AI β Z.ai (GLM series)
- Console: z.ai (separate account from the domestic BigModel platform; USD billing)
- Steps: Sign up β API Keys β Create β copy β choose pay-as-you-go or prepaid bundles.
- Base URL:
https://api.z.ai/api/paas/v4(OpenAI-compatible); Anthropic-compatible:https://api.z.ai/api/anthropicβ works with Claude Code and 20+ coding tools
Official docs: Z.ai docs
2.12 MiniMax International
- Console: platform.minimax.io (separate account from platform.minimaxi.com; USD billing)
- Steps: Sign up β API Keys β Create β copy β top up.
- Base URL:
https://api.minimax.io/v1(OpenAI-compatible); Anthropic-compatible: https://api.minimax.io/anthropic
Official docs: MiniMax international docs
2.13 SiliconFlow International
- Console: siliconflow.com (separate account from siliconflow.cn)
- Steps: Sign up β API Keys β Create β copy. Free credits for new accounts; serves many open-source models (DeepSeek, Qwen, GLM, etc.).
- Base URL:
https://api.siliconflow.com/v1(OpenAI-compatible)
Official docs: SiliconFlow international docs
2.14 Baidu ERNIE, Tencent Hunyuan, iFlytek Spark, and Baichuan (International)
None of these vendors publishes a self-serve international API key page today. Baidu and Tencent onboard international customers through Baidu AI Cloud International and Tencent Cloud International respectively (console accounts separate from their domestic platforms). iFlytek Spark and Baichuan currently operate domestic-only API platforms β international access requires contacting their business/sales teams rather than self-serve signup.
Official docs: Baidu Qianfan docs Official docs: Tencent Hunyuan docs Official docs: iFlytek Spark docs Official docs: Baichuan docs
2.15 Xiaomi MiMo (single global platform)
- Console: platform.xiaomimimo.com (try models in the browser at aistudio.xiaomimimo.com)
- Steps: Sign up β API Keys β Create New Key β copy immediately (shown once). New accounts get a small trial credit.
- Notes: Like DeepSeek, Xiaomi runs one platform serving all regions β no separate domestic/international consoles for pay-as-you-go. Two usage modes:
- Pay-as-you-go MiMo API (
sk-...key): billed per token. - Token Plan subscription (
tp-...individual /ttp-...team keys): fixed monthly fee with dedicated regional endpoints β Chinahttps://token-plan-cn.xiaomimimo.com/v1, Singaporehttps://token-plan-sgp.xiaomimimo.com/v1, Europehttps://token-plan-ams.xiaomimimo.com/v1(cluster choice matters for latency). - Base URL:
https://api.xiaomimimo.com/v1(OpenAI-compatible); Anthropic-compatible:https://api.xiaomimimo.com/anthropicβ works with Claude Code. Model IDs likemimo-v2.6-pro/mimo-v2.6-flash.
Official docs: Xiaomi MiMo docs
2.16 StepFun International (StepFun overseas site)
- Console: platform.stepfun.ai (separate account from platform.stepfun.com; USD billing)
- Steps: Sign up β Interface Keys (platform.stepfun.ai/interface-key) β Create API Key β copy immediately. Real-name requirements differ from the China site β check the console for the current policy.
- Notes: The international site mirrors the domestic billing channels: pay-as-you-go API keys and the Step Plan Oversea subscription. The two channels use different endpoints, and a wrong channel does not automatically fall back to subscription credits.
- Pay-as-you-go (OpenAI-compatible): https://api.stepfun.ai/v1
- Step Plan Oversea (OpenAI-compatible path): https://api.stepfun.ai/step_plan/v1
- Step Plan Oversea (Anthropic-compatible path, for Claude Code): https://api.stepfun.ai/step_plan
- Data/compliance: the international site applies its own privacy policy with processing and storage located outside mainland China β verify before sending sensitive code or customer data.
2.17 Meta (Muse series)
- Console: dev.meta.ai (the Meta Model API β currently a public preview)
- Steps: Sign up with email/phone or Facebook/Google/GitHub β add a payment method (requests fail without one) β API keys β Create API key β copy immediately (shown once; the official examples read it from the
MODEL_API_KEYenvironment variable). - Notes:
- Closed frontier models:
muse-spark-1.3(recommended for new projects; audio work should usemuse-spark-1.2) andmuse-wonder-1.0. Reasoning cannot be disabled β tune it withreasoning_effort(minimal / low / medium / high / xhigh / max). - Two pricing tiers: Standard (no training on your prompts; 1.25 input / 4.25 output per 1M tokens) and Contributor (over 90% cheaper, but Meta trains on your prompts and completions β never send confidential data through it). New accounts get a one-time $20 credit; paid limits are 3,000 requests / 4M tokens per minute.
- Open-weight siblings: Muse Spark Open (816B, custom Muse Model License) and Muse Glimmer 30B (Apache 2.0) β see Β§6.3.
- Restricted regions (Meta's list, updated September 2026) include mainland China, Hong Kong, Macao, Russia, Iran, and North Korea.
- Base URL: https://api.meta.ai/v1
- Data/compliance: the API is a public preview with no change-notice commitment β re-check pricing and model availability before committing a budget.
Official docs: Meta Model API docs
Why this matters:_ all platforms in 2.7β2.17 are separate systems from the domestic Chinese platforms in Section 3 β different consoles, accounts, and endpoints, and keys do not work across the two. Choose based on where you are and which currency you bill in._
Official docs: StepFun international docs
3. First-Party Providers: China-Based (China Domestic Platforms)
This section covers the domestic (China) platforms β for users inside China, paying in Β₯, with the lowest latency. These platforms require real-name verification (shi-ming-ren-zheng, an identity check linked to your government ID) and most are OpenAI-compatible, which makes them drop-in replacements.
β οΈ Each vendor below also runs a separate international platform with its own account system and USD billing (see Sections 2.7β2.17). Keys do not work across the two. (DeepSeek and Xiaomi MiMo are single-platform exceptions serving all regions; iFlytek Spark and Baichuan currently have no international platform at all.)
Quick reference β domestic platforms:
Vendor Domestic console Domestic Base URL (OpenAI-compatible) DeepSeek platform.deepseek.com api.deepseek.com Alibaba Qwen (DashScope) bailian.console.aliyun.com dashscope.aliyuncs.com/compatible-mode/v1 ByteDance Volcano Ark console.volcengine.com/ark ark.cn-beijing.volces.com/api/v3 Moonshot (Kimi) platform.moonshot.cn api.moonshot.cn/v1 Zhipu GLM (BigModel) open.bigmodel.cn open.bigmodel.cn/api/paas/v4 MiniMax platform.minimaxi.com api.minimaxi.com/v1 StepFun (Step) platform.stepfun.com api.stepfun.com/v1 iFlytek Spark console.xfyun.cn (Spark service) spark-api-open.xf-yun.com/v1 Baichuan platform.baichuan-ai.com api.baichuan-ai.com/v1 Baidu ERNIE (Qianfan) Qianfan console qianfan.baidubce.com/v2 Tencent Hunyuan Tencent Cloud console api.hunyuan.cloud.tencent.com/v1 Xiaomi MiMo platform.xiaomimimo.com api.xiaomimimo.com/v1 Huawei Cloud (Pangu/MaaS) Huawei Cloud console β ModelArts Studio api.modelarts-maas.com/openai/v1 SiliconFlow siliconflow.cn api.siliconflow.cn/v1 China Telecom (TeleChat) teleai.com.cn api-maas.teleai.com.cn/v1 China Mobile (JiTian) ecloud.10086.cn β MoMA zhenze-huhehaote.cmecloud.cn/v1 (per region) China Unicom (YuanJing) maas.ai-yuanjing.com maas-api.ai-yuanjing.com/openapi/compatible-mode/v1
Vendor-specific details follow.
3.1 DeepSeek
- Console: platform.deepseek.com (separate from the chat app at chat.deepseek.com)
- Steps: Register (a +86 phone number is the typical route) β API Keys β Create new API key β copy β Top Up with credits (from ~$2 / Β₯10).
- Notes: Fully OpenAI-compatible, plus an Anthropic-compatible endpoint at
https://api.deepseek.com/anthropic, so it can back tools like Claude Code directly.
Official docs: DeepSeek API docs
3.2 Alibaba Cloud Qwen (Model Studio / DashScope)
- Console: bailian.console.aliyun.com (China account, real-name verification required)
- Steps:
- Register and open Model Studio.
- Open the API Key page and select your region first β each region has independent endpoints, keys, and model lists, and they cannot be mixed.
- Click Create API Key, choose the owning account/business space, set permissions (IP whitelist and model whitelist are supported).
- Copy the key β shown once.
- Notes: New accounts typically receive a large free token grant. Base URL:
[https://dashscope.aliyuncs.com/compatible-mode/v1](https://dashscope.aliyuncs.com/compatible-mode/v1.).
Official docs: Alibaba Model Studio docs
3.3 ByteDance Volcano Engine (Doubao / Seed models)
- Console: console.volcengine.com/ark β API Key Management
- Steps: Register a Volcano Engine account β real-name verification β create an inference endpoint or use the default β generate an API key.
- Base URL: https://ark.cn-beijing.volces.com/api/v3
Official docs: Volcano Ark docs
3.4 Moonshot AI (Kimi)
- Console: platform.moonshot.cn
- Steps: Register β API Keys β Create β copy β top up in Β₯.
- Base URL:
https://api.moonshot.cn/v1; Anthropic-compatible: https://api.moonshot.cn/anthropic
Official docs: Moonshot Kimi docs
3.5 Zhipu AI (GLM series, BigModel)
- Console: open.bigmodel.cn
- Steps: Register β API Keys β Create β copy β real-name verification for higher limits.
- Base URL:
https://open.bigmodel.cn/api/paas/v4; Anthropic-compatible (coding tools like Claude Code): https://open.bigmodel.cn/api/anthropic
Official docs: Zhipu BigModel docs
3.6 MiniMax
- Console: platform.minimaxi.com
- Steps: Register β API Keys β Create new key β copy β top up.
- Base URL:
https://api.minimaxi.com/v1; Anthropic-compatible: https://api.minimaxi.com/anthropic
Official docs: MiniMax docs
3.7 Baidu ERNIE and Tencent Hunyuan
Both are accessed through their domestic cloud consoles (Qianfan for Baidu, Cloud API / OpenAPI for Tencent Hunyuan). Steps are the standard pattern: register cloud account β real-name verification β enable the model service β create an API key in the console. Tencent Hunyuan's endpoint is https://api.hunyuan.cloud.tencent.com/v1 (OpenAI-compatible).
Official docs: Baidu Qianfan docs Official docs: Tencent Hunyuan docs
3.8 Xiaomi MiMo
- Console: platform.xiaomimimo.com β note this is a single global platform serving all regions (no separate international console; see Β§2.15 for the Token Plan regional clusters)
- Steps: Sign up β API Keys β Create New Key β copy immediately (shown once). Model IDs like
mimo-v2.6-pro/mimo-v2.6-flash. - Base URL:
https://api.xiaomimimo.com/v1(OpenAI-compatible); Anthropic-compatible: https://api.xiaomimimo.com/anthropic
Official docs: Xiaomi MiMo docs
3.9 Huawei Cloud β ModelArts Studio MaaS (Pangu)
Huawei's model offering runs through Huawei Cloud ModelArts Studio (MaaS) β a cloud model-hosting platform serving both Huawei's proprietary Pangu models (openPangu-2.0-Pro/Flash) and leading open-source models (DeepSeek, GLM, Kimi K2.6, Qwen3) on Ascend infrastructure.
- Console: Huawei Cloud console β ModelArts Studio β Model-as-a-Service (MaaS)
- Steps: Register a Huawei Cloud account β real-name verification β open ModelArts Studio β enable the model you want in the Model Plaza β go to the model's API call details page β create an API Key β copy immediately (shown once).
- Base URL (OpenAI-compatible):
https://api.modelarts-maas.com/openai/v1β currently the OpenAI-compatible endpoint serves only the Guizhou region; the Hong Kong site uses a regional host such ashttps://api-ap-southeast-1.modelarts-maas.com/openai/v1. Model, API Key, and endpoint must belong to the same region β always copy the exact URL from the console's call-details page. - Notes: Model IDs follow plain names (
openpangu-2.0-pro,glm-5.3,kimi-k2.6,deepseek-v4.1-flash,qwen3-32b). Enterprise VPC/dedicated instances use private gateway URLs instead.
Official docs: Huawei Cloud ModelArts Studio MaaS docs
3.10 SiliconFlow (open-model hosting)
Worth adding to your list if you want one Chinese platform that serves many open-source models (DeepSeek, Qwen, GLM, and more):
- Console: siliconflow.cn
- Base URL: https://api.siliconflow.cn/v1
- Free credits for new accounts; OpenAI-compatible.
Official docs: SiliconFlow docs
3.11 The Three Major Telecom Operators (China Mobile / China Telecom / China Unicom)
All three carriers run proprietary LLMs with self-serve API platforms, hosted on their respective clouds. They are geared toward enterprise/government customers, so expect real-name verification and purchase-first flows rather than free trial credits.
Carrier Model Cloud Console / Platform OpenAI-compatible Base URL China Telecom TeleChat (Xingchen) CTYun (Tianyi Cloud) teleai.com.cn (Tianyi AI Open Platform); Xingchen MaaS in the CTYun console https://api-maas.teleai.com.cn/v1 China Mobile JiTian ECloud (China Mobile Cloud) ecloud.10086.cn β JiTian AI β MoMA model service platform https://<region>.cmecloud.cn/v1 (region-specific, e.g. zhenze-huhehaote.cmecloud.cn/v1) China Unicom YuanJing CUCloud maas.ai-yuanjing.com (YuanJing MaaS platform) https://maas-api.ai-yuanjing.com/openapi/compatible-mode/v1
- China Telecom: on the Tianyi AI Open Platform the flow is real-name verification β purchase a plan β create an application β call the API, with
AppID+AppKeyas credentials. For the OpenAI-compatible MaaS endpoint, create a key in the Xingchen MaaS console (System Management β API Key). Model IDs likeTeleChat3-438B-A24BandXing4.0-29B-A4B; the official docs show the endpoint working in Claude Code and other coding tools. The Xingchen TokenHub gateway (https://ai.ctaigw.cn/v1, international:https://ai.ctaigw.com/{region}) serves global regions (amer/eu/as). - China Mobile: register at ECloud β real-name verification β open the MoMA console β Model Plaza β pick a model β API Invocation β Get API Key. Note that API addresses are region-specific (e.g.
https://zhenze-huhehaote.cmecloud.cn/v1/chat/completions) β always copy the exact URL from the console for your deployed model. Works with Chatbox, Cherry Studio, and Dify. - China Unicom: register at the YuanJing MaaS platform β Toolbox β API Key Management β Create β copy. Use the OpenAI-compatible URL above (do not append
/chat/completionsin tools that auto-append it). For AI coding tools, CUCloud also sells a Token Plan subscription (cucloud.cn/product/tokenplan.html) with a dedicated API Key + Base URL issued from the console after subscribing.
These are niche choices for most developers β the main reasons to pick one are data-sovereignty requirements, telecom cloud procurement, or carrier-bundled deals β but they are fully functional OpenAI-compatible endpoints.
Official docs: China Telecom Tianyi AI Official docs: China Mobile ECloud Official docs: China Unicom YuanJing
3.12 StepFun (Step series)
- Console: platform.stepfun.com (international: platform.stepfun.ai)
- Steps:
- Register with a Chinese mobile number (no VPN required for domestic access).
- Complete real-name verification β required for free-tier users and before any paid usage (User Center β Account Management β Account Info; face verification via Alipay scan).
- In the console, go to Account Management β Interface Keys (platform.stepfun.com/interface-key) β Create API Key β copy and store it (shown once).
- Notes: New accounts receive free token grants. The Step Plan subscription additionally exposes an Anthropic-compatible endpoint at
https://api.stepfun.com/step_planβ for tools like Claude Code, setANTHROPIC_BASE_URLto this address (without/v1; the client appends/v1/messagesautomatically). - Base URL:
https://api.stepfun.com/v1(OpenAI-compatible)
Official docs: StepFun docs
3.13 iFlytek Spark
- Console: console.xfyun.cn (iFlytek Open Platform β Spark LLM service)
- Steps:
- Register and verify β create an application in the console.
- Critical step: open the "Spark LLM" service page and enable a model version for that application (Lite / Pro / Max / 4.0Ultra) β skipping this causes persistent authorization failures.
- Copy the application's APIPassword.
- Notes (biggest gotcha): the OpenAI-compatible endpoint authenticates with the APIPassword, not the APIKey or APISecret β those two belong to the legacy WebSocket interface, and using them returns 401. The Lite version is free, ideal for verifying connectivity before upgrading to Pro/Max/4.0Ultra.
- Base URL:
https://spark-api-open.xf-yun.com/v1(OpenAI-compatible; the trailing/v1is required) - International: none β Spark has no self-serve overseas platform; international access goes through iFlytek's business channels.
Official docs: iFlytek Spark docs
3.14 Baichuan
- Console: platform.baichuan-ai.com β API Key management
- Steps: Register β create and copy a key on the API Key page β real-name verification and top-up.
- Base URL:
https://api.baichuan-ai.com/v1(OpenAI-compatible) - International: none β domestic platform only; contact the vendor for overseas access.
Official docs: Baichuan docs
3.15 Others worth knowing
Kunlun Wanwei's Tiangong, SenseTime's SenseNova, and 01.AI (Yi series) also offer OpenAI-compatible APIs following the same pattern: register β real-name verification β create a key in the console. Confirm exact entry points and endpoints against each vendor's official documentation.
Official docs: Kunlun Tiangong Official docs: SenseTime SenseNova Official docs: 01.AI
4. Enterprise Cloud Platforms
If your organization already runs on a hyperscaler, model access goes through that platform instead of the vendor console. Keys are managed as cloud credentials, not simple API keys.
4.1 Azure OpenAI (Microsoft)
- Request access to Azure OpenAI in your Azure subscription.
- In the Azure Portal, create an Azure OpenAI Resource.
- Deploy a model (Model deployments β e.g. deploy a GPT model).
- Get credentials from Keys and Endpoint in the resource overview.
- Use
https://<your-resource>.openai.azure.com/openai/deployments/<deployment>/chat/completions?api-version=...
Official docs: Azure OpenAI docs
4.2 AWS Bedrock
- Open Amazon Bedrock in the AWS Console.
- Enable model access under Bedrock configurations β Model access (approve each provider's models).
- No per-model API key exists β authenticate with standard AWS credentials (access key + secret key, or IAM roles), typically via the AWS SDK or the
boto3client.
Official docs: Amazon Bedrock docs
4.3 Google Vertex AI
- Create/select a GCP project and enable the Vertex AI API.
- Authenticate with
gcloud auth application-default loginor a service-account key JSON. - Call models through
https://<region>-aiplatform.googleapis.com/...using the Google Cloud SDKs.
Why use these? Enterprise compliance, data residency guarantees (no training on your data), VPC integration, and consolidated billing. The trade-off: more setup than a plain API key.
Official docs: Vertex AI generative AI docs
5. Third-Party Aggregators and Inference Providers
These give you one signup, one bill, one integration β often covering hundreds of models.
5.1 OpenRouter β one key, hundreds of models
- Console: openrouter.ai β Settings β Keys
- Steps: Sign up β create a key β copy β optionally add credit.
- Notes: The single most popular aggregator. OpenAI-compatible at
https://openrouter.ai/api/v1. Models are addressed asvendor/model(e.g.anthropic/claude-sonnet-5,deepseek/deepseek-chat). Routes tagged:freecost nothing but have modest daily caps β adding a small credit balance raises free-route limits.
Official docs: OpenRouter docs
5.2 Groq β ultra-fast inference
- Console: console.groq.com β API Keys
- Steps: Sign up (no card for the free tier) β create a key β copy.
- Base URL:
https://api.groq.com/openai/v1(OpenAI-compatible). Serves Llama and other open models at extreme speed; watch the tight per-minute limits.
Official docs: Groq docs
5.3 Together AI
- Console: console.together.xyz β Settings β API Keys
- Base URL:
https://api.together.xyz/v1. Open models, serverless endpoints, and fine-tuning.
Official docs: Together AI docs
5.4 Fireworks AI
- Console: fireworks.ai β sign up β API Keys
- Base URL:
https://api.fireworks.ai/inference/v1. Known for serving open models fast, including multimodal ones.
Official docs: Fireworks AI docs
5.5 Cerebras Cloud
- Console: cloud.cerebras.ai β API Keys
- Steps: Email signup, no waitlist, no card for free quotas β generate a key (
csk-...). - Base URL:
https://api.cerebras.ai/v1. Wafer-scale inference β some of the fastest token generation available.
Official docs: Cerebras inference docs
5.6 GitHub Models
- Access: GitHub Marketplace β Models (or the Models playground in github.com)
- Steps: Sign in with your GitHub account β accept terms β create a fine-grained personal access token (PAT) per the current GitHub Models docs.
- Notes: Free, rate-limited access to a catalog of frontier models for prototyping β ideal if you already live on GitHub.
Official docs: GitHub Models docs
5.7 Cloudflare Workers AI
- Console: dash.cloudflare.com
- Steps: Create a free account β Workers AI β create an API token with Workers AI permissions.
- Notes: Free daily allocation of "neurons"; good for lightweight edge deployments.
Official docs: Cloudflare Workers AI docs
5.8 Relay/gateway services
Services such as LinkModel, AiHubMix, and similar resellers sell a single key routed to many official providers, sometimes below official rates. Verify retention and compliance policies carefully before sending sensitive data through any third-party gateway.
Official docs: LinkModel Official docs: AiHubMix
5.9 NVIDIA NIM (build.nvidia.com)
NVIDIA runs hosted inference for its own Nemotron family and a large open-model catalog (DeepSeek, Llama, Qwen, GLM, Kimi, Mistral, gpt-oss, and more) β GPU-optimized and served behind an OpenAI-compatible API.
- Console: build.nvidia.com (join the free NVIDIA Developer Program β email only, no credit card)
- Steps: Create an account β open any model page or Settings β API Keys β Generate API Key β copy the
nvapi-...key immediately (shown once). - Notes: The free tier is for prototyping only β rate-limited (~40 RPM for most models, no per-token billing). Production serving requires an NVIDIA AI Enterprise license. The same NIM containers can be downloaded and self-hosted on NVIDIA GPUs, with an identical API.
- Base URL:
https://integrate.api.nvidia.com/v1(OpenAI-compatible; model IDs usepublisher/modelformat, e.g.nvidia/llama-3.3-nemotron-super-49b-v1.5)
Official docs: NVIDIA NIM docs
6. Providers Without a Public API: Copilot, Apple, and Friends
Not every big-name model can be called with a plain API key. These offerings are products, not platforms β here is what they are and what to use instead.
6.1 Microsoft Copilot and GitHub Copilot
Why there is no key to grab: Microsoft Copilot (Windows/Edge/365 Copilot) and GitHub Copilot are closed, subscription-based products. Microsoft does not sell their underlying models as a pay-as-you-go public API β you subscribe to the product, not to the model.
What to use instead:
- Azure OpenAI / Azure AI Foundry (Β§4.1) β Microsoft's official API platform for GPT models, with enterprise compliance. This is the Microsoft API key you are looking for.
- GitHub Models (Β§5.6) β free, rate-limited prototyping access to a model catalog with just a GitHub account.
- GitHub Copilot subscribers can also point some open-source coding tools at Copilot-backed endpoints, but this is a product feature, not a general-purpose API.
Official docs: Microsoft 365 Copilot docs Official docs: GitHub Copilot docs
6.2 Apple Intelligence
Why there is no key to grab: Apple's models (the on-device model and the server-side Private Cloud Compute models) power Apple Intelligence on Apple devices only. Apple offers no public LLM API, no developer key, and no per-token billing β its server models are locked to Apple hardware and even they cannot be called from your own apps. Apple's external AI integration is a consumer ChatGPT partnership, not a developer offering.
What to use instead: for iOS/macOS apps, call any provider from this article through your own backend (OpenAI, Gemini, Anthropic all have official Swift SDKs). There is no Apple-hosted alternative.
Official docs: Apple Intelligence developer docs
6.3 Meta (Muse open weights)
Meta now operates an official hosted API for its Muse series (see Β§2.17), but its frontier models (Muse Spark, Muse Wonder) remain closed. The open-weight side of the family:
- Muse Spark Open (October 2026): an 816B-parameter open-weight model (42B active, 1M-token context) under the custom Muse Model License β free for most uses, but API resellers with over $20M annual revenue must sign a separate agreement with Meta. Served by Together, Fireworks, Groq, Baseten, Modal, Nebius, and OpenRouter; weights downloadable from Hugging Face, SageMaker AI, Google Cloud Model Garden, and Microsoft Foundry.
- Muse Glimmer 30B (Apache 2.0): a 30B model built for local agent workflows β run it with Ollama, LM Studio, vLLM, llama.cpp, or ExecuTorch. No API key and no per-token cost.
This supersedes the earlier Llama-only situation: Meta's model line has moved to the Muse family, and open-weight releases now sit alongside a first-party API instead of replacing one.
Official docs: Meta Model API docs
6.4 The pattern
A company "having a big model" does not imply it sells API access. The question to ask is: does the vendor operate a public, self-serve, token-billed endpoint? If not, the model reaches you either through a product subscription (Copilot), locked hardware (Apple), or third-party hosting of open weights (Muse Glimmer via Ollama, or open models on Groq/NIM).
7. Self-Hosted and Locally Trained Models (OpenAI-Compatible Servers)
The last stop on the key spectrum is no key at all β or rather, a key you invent yourself. Every serious local runtime now exposes an OpenAI-compatible endpoint (/v1/chat/completions), which means the same OpenAI SDK, the same tools, and the same code you used for cloud providers work unchanged against a model running on your own GPU β including checkpoints you trained or fine-tuned yourself.
7.1 The universal pattern
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1", # your local server
api_key="ollama", # local servers ignore it, but the SDK needs a non-empty string
)
response = client.chat.completions.create(
model="qwen3:32b",
messages=[{"role": "user", "content": "Hello!"}],
)from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1", # your local server
api_key="ollama", # local servers ignore it, but the SDK needs a non-empty string
)
response = client.chat.completions.create(
model="qwen3:32b",
messages=[{"role": "user", "content": "Hello!"}],
)Swap the base URL and model name and this exact code talks to any runtime below. In third-party tools (Chatbox, Cherry Studio, Cline, Difyβ¦), pick the "Ollama" or "OpenAI Compatible" provider, enter the local Base URL, and type any placeholder key.
7.2 Local runtimes compared
Runtime Install & start Base URL Typical use Ollama ollama pull qwen3:32b then ollama serve http://localhost:11434/v1 Easiest start; huge model library; one command per model LM Studio GUI app β download model β Developer tab β Start server http://localhost:1234/v1 Desktop users who prefer a GUI; built-in model search vLLM pip install vllm then vllm serve <model-or-checkpoint> --api-key sk-mysecret http://localhost:8000/v1 Production / serving your own trained checkpoints; high-throughput, continuous batching SGLang pip install sglang then python -m sglang.launch_server http://localhost:30000/v1 High-performance serving, strong structured-output support llama.cpp build, then llama-server -m model.gguf http://localhost:8080/v1 CPU/low-resource machines, GGUF quantized models Xinference / LocalAI pip install + launch See their docs Multi-model hosting on your own cluster, OpenAI-compatible by design
Authentication notes: Ollama and LM Studio ignore the key (anything non-empty works); vLLM enforces a real key only if you pass --api-key. If you expose a local server beyond localhost β LAN or public β always set an API key and put it behind HTTPS/reverse proxy, because an unauthenticated OpenAI endpoint is as dangerous as a leaked cloud key.
7.3 Training or fine-tuning your own model, then serving it OpenAI-style
The full self-sovereign pipeline, all OpenAI-spec end to end:
- Pick a base model β download open weights (Qwen, GLM, Llama, DeepSeek, Mistral) from Hugging Face or ModelScope.
- Fine-tune with LoRA/QLoRA β mainstream tools: LLaMA-Factory (WebUI, zero-code), Unsloth (single-GPU, fast), Axolotl (config-driven). Export merged weights or an adapter.
- Serve the checkpoint β point vLLM (
vllm serve ./my-finetuned-model) or SGLang at your output directory; or wrap a GGUF in an OllamaModelfile(FROM ./model.ggufβollama create mymodel -f Modelfile). - Call it like OpenAI β
base_urlpoints at your server,modelis your checkpoint's name. Your app, tools, and agent frameworks cannot tell the difference between this and a cloud API.
Why this route exists: zero per-token cost, full data privacy (nothing leaves your machine), no rate limits, and complete control over the model's behavior. The trade-offs are hardware cost, ops burden, and the quality gap between your fine-tune and frontier cloud models β for most projects the sweet spot is a fine-tuned small/medium open model served with vLLM for a narrow task, with cloud APIs for the heavy reasoning.
8. Quick Reference Table
International first-party
Provider Console URL Key prefix Free tier Base URL OpenAI platform.openai.com sk-proj-... No (billing required) api.openai.com/v1 Anthropic console.anthropic.com sk-ant-... No (credits required) api.anthropic.com Google AI Studio aistudio.google.com/apikey AIza... Yes (rate-limited) generativelanguage.googleapis.com xAI console.x.ai xai-... Limited api.x.ai/v1 Mistral console.mistral.ai varies Free/Experiment mode api.mistral.ai/v1 Cohere dashboard.cohere.com varies Trial keys api.cohere.com Meta (Muse) dev.meta.ai MODEL_API_KEY $20 one-time credit api.meta.ai/v1
China-based first-party (domestic platforms in Β§3; their international platforms in Β§2.7β2.17)
Vendor Domestic console / Base URL International console / Base URL DeepSeek platform.deepseek.com Β· api.deepseek.com Same single platform (no separate intl endpoint) Alibaba Qwen bailian.console.aliyun.com Β· dashscope.aliyuncs.com/compatible-mode/v1 Alibaba Intl Model Studio Β· dashscope-intl.aliyuncs.com/compatible-mode/v1 Volcano Ark (Doubao) console.volcengine.com/ark Β· ark.cn-beijing.volces.com/api/v3 BytePlus ModelArk Β· ark.ap-southeast.bytepluses.com/api/v3 Moonshot (Kimi) platform.moonshot.cn Β· api.moonshot.cn/v1 platform.moonshot.ai Β· api.moonshot.ai/v1 Zhipu GLM open.bigmodel.cn Β· open.bigmodel.cn/api/paas/v4 z.ai Β· api.z.ai/api/paas/v4 MiniMax platform.minimaxi.com Β· api.minimaxi.com/v1 platform.minimax.io Β· api.minimax.io/v1 StepFun (Step) platform.stepfun.com Β· api.stepfun.com/v1 platform.stepfun.ai Β· api.stepfun.ai/v1 iFlytek Spark console.xfyun.cn Β· spark-api-open.xf-yun.com/v1 None (business channels only) Baichuan platform.baichuan-ai.com Β· api.baichuan-ai.com/v1 None (business channels only) Baidu ERNIE Qianfan console Β· qianfan.baidubce.com/v2 Via Baidu AI Cloud International Tencent Hunyuan Tencent Cloud console Β· api.hunyuan.cloud.tencent.com/v1 Via Tencent Cloud International Xiaomi MiMo platform.xiaomimimo.com Β· api.xiaomimimo.com/v1 Same single platform (Token Plan clusters: cn/sgp/ams subdomains)
β οΈ Keys are platform-bound: a domestic-platform key (.cn hosts, Β₯ billing) cannot call the international endpoint, and an international key cannot call the domestic endpoint. The two account systems do not share balance or keys.
Aggregators
Provider Console URL Base URL Highlights OpenRouter openrouter.ai/settings/keys openrouter.ai/api/v1 Hundreds of models, :free routes Groq console.groq.com/keys api.groq.com/openai/v1 Free tier, very fast Together console.together.xyz api.together.xyz/v1 Open models + fine-tuning Fireworks fireworks.ai api.fireworks.ai/inference/v1 Fast open-model serving Cerebras cloud.cerebras.ai api.cerebras.ai/v1 Free tier, extreme speed GitHub Models github.com marketplace Azure-compatible Free with GitHub account Cloudflare Workers AI dash.cloudflare.com REST/bindings Free daily neurons NVIDIA NIM build.nvidia.com integrate.api.nvidia.com/v1 Free prototyping, Nemotron + open models
9. Using Your API Key in Tools and Frameworks
9.1 The universal pattern: environment variables
Every tool and SDK can read keys from environment variables. Set them once:
# macOS / Linux β add to ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="sk-proj-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="AIza..."
export DEEPSEEK_API_KEY="sk-..."
# Windows PowerShell (permanent)
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-proj-...", "User")# macOS / Linux β add to ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="sk-proj-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="AIza..."
export DEEPSEEK_API_KEY="sk-..."
# Windows PowerShell (permanent)
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-proj-...", "User")For multi-key projects, use a .env file plus python-dotenv or dotenv β and add .env to .gitignore before your first commit.
9.2 First API call (copy-paste ready)
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'Because DeepSeek, Moonshot, Zhipu, Groq, Together, OpenRouter, and most others are OpenAI-compatible, the same code works everywhere β just swap the base URL and model name:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DEEPSEEK_API_KEY"],
base_url="https://api.deepseek.com",
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Gemini via the official SDK
from google import genai
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
print(client.models.generate_content(
model="gemini-2.5-flash", contents="Hello!"
).text)from openai import OpenAI
client = OpenAI(
api_key=os.environ["DEEPSEEK_API_KEY"],
base_url="https://api.deepseek.com",
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Gemini via the official SDK
from google import genai
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
print(client.models.generate_content(
model="gemini-2.5-flash", contents="Hello!"
).text)9.3 Popular tools and where to paste the key
Tool Where to configure Cursor Settings β Models β add provider + API key Claude Code ANTHROPIC_API_KEY env var; point to OpenAI-compatible backends via ANTHROPIC_BASE_URL Cline / Roo Code / Continue (VS Code) Extension settings β provider dropdown β paste key; "OpenAI Compatible" option accepts a custom Base URL Chatbox / Cherry Studio / LobeChat Settings β Model provider β paste API Key + Base URL + model name Dify Settings β Model Providers β select vendor β paste key n8n / Langflow / Flowise Credentials section β create credential for the provider β paste key Ollama-connected frontends No key needed for local models; add remote providers with keys
9.4 Framework integration
# LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o", api_key=os.environ["OPENAI_API_KEY"])
from langchain_anthropic import ChatAnthropic
claude = ChatAnthropic(model="claude-sonnet-5", api_key=os.environ["ANTHROPIC_API_KEY"])
// OpenAI Node SDK
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });# LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o", api_key=os.environ["OPENAI_API_KEY"])
from langchain_anthropic import ChatAnthropic
claude = ChatAnthropic(model="claude-sonnet-5", api_key=os.environ["ANTHROPIC_API_KEY"])
// OpenAI Node SDK
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });The one-base-URL trick: for any OpenAI-compatible tool that only lets you pick OpenAI as vendor, set the Base URL to an aggregator like https://openrouter.ai/api/v1 and use model IDs like google/gemini-2.5-flash β one key then serves every model the tool can reach.
10. Free Options Compared
Option Truly free? Catch Google AI Studio Yes, rate-limited free tier Free-tier data may be used for training Groq / Cerebras free tiers Yes, generous daily caps Tight per-minute limits, open models only Mistral Free/Experiment mode Yes Usage and rate limits OpenRouter :free routes Yes Low daily request caps GitHub Models Yes Rate-limited, prototyping only Cloudflare Workers AI Free daily allocation Smaller models NVIDIA NIM (build.nvidia.com) Free prototyping tier Rate-limited (~40 RPM); production requires AI Enterprise license DeepSeek / others Pay-as-you-go only Very cheap, but not free (new accounts may get a small one-time grant)
11. API Key Security: 7 Rules You Should Not Skip
A leaked key means a drained balance and, at worst, a five-figure bill. These rules are non-negotiable:
- Never hardcode keys. Use
.envfiles, environment variables, or a secrets manager (Vault, AWS Secrets Manager, Doppler). Never paste keys into client-side or mobile code β extract-and-abuse is trivial. - Never commit keys to Git. Put
.envin.gitignorefirst. If a key ever lands in a commit, rotate it immediately β even in a private repo. - Set spend limits immediately. Configure monthly caps or prepaid-only billing on every provider. Your maximum leak exposure should be the cap, not your account balance.
- One key per project/environment. Separate dev/staging/production keys so a leaked dev key cannot touch production quotas, and rotation is painless.
- Restrict keys where supported. OpenAI project keys, DashScope IP/model whitelists, and Azure policy constraints all reduce blast radius.
- Rotate every 3β6 months β and immediately after any suspected exposure.
- Check usage logs weekly. Unexpected spikes are the classic signature of a compromised key. Revoke first, investigate second.
For production apps, route all model traffic through your own backend proxy so end users never see any key, and prefer short-lived scoped tokens where the provider supports them (e.g. DashScope temporary keys, max 1800 s).
12. Troubleshooting Common Errors
Error Likely cause Fix 401 Unauthorized Wrong key, revoked key, or wrong header format Re-copy the key; confirm Authorization: Bearer <key> 429 Rate Limit Exceeded Tier too low or burst over limit Add retry with exponential backoff; top up to raise tier insufficient_quota / balance errors Billing not set up or credits exhausted Add payment method or top up in the console model not found Wrong model ID for that provider/base URL Check the provider's model list; aggregators use vendor/model IDs Works in curl, fails in tool Wrong Base URL or region mismatch (DashScope regions cannot mix) Verify the exact compatible-mode endpoint for your region Chinese vendor key gets 401 on a different endpoint Key was created on the domestic platform but pointed at the international Base URL (or vice versa) β they are separate account systems Match key and endpoint: moonshot.cn β moonshot.cn console, z.ai β z.ai console, etc. (see Section 3 table) Key shown as AQ.Ab8... (Gemini) That is a CLI OAuth token, not an API key Regenerate from aistudio.google.com/apikey
13. Important: When Information Goes Stale
The LLM API landscape moves fast β consoles get redesigned, endpoints migrate, free tiers appear and vanish, vendors merge platforms, and entire products are retired. If any method in this article no longer matches what you see, or stops working, do not assume the provider is gone β the process has probably just changed.
When that happens, refresh your information through any of these channels:
- Ask an AI assistant β ChatGPT, Claude, Gemini, Kimi, Doubao, DeepSeek, or any assistant you use daily. Phrase it concretely, e.g. "How do I get a Z.ai API key in 2026? The old steps no longer match the console." Modern assistants can search the web and will usually surface the current console path, pricing, and signup flow.
- Search engines β query for the provider name plus keywords like
API key,price, or the current year (e.g. "DeepSeek API key 2026"). Prefer results from the provider's official domain (platform.xxx.com,docs.xxx.com,help center) over third-party blog posts, which age even faster. - The provider's own docs and announcement pages β most consoles have a "What's new" / changelog or docs home that lists endpoint migrations before they happen.
- Developer communities β GitHub issues/discussions of the tools you use (Cline, Chatbox, OpenRouter, etc.), Stack Overflow, Reddit (r/LocalLLaMA), V2EX, and the vendors' own social media channels (X, WeChat official accounts, Weibo, Jike) β breaking changes are almost always reported there within hours.
Two habits that save time: bookmark each provider's official docs home so a console redesign never strands you, and date-check any tutorial before following it β an undated guide is often three consoles behind.
Summary
The universal workflow is identical everywhere: create an account β open the provider's console β create a key β copy it once β set up billing (unless there is a free tier) β store it in environment variables. Google AI Studio is the best genuinely free starting point; DeepSeek and the Chinese platforms are the cheapest pay-as-you-go options; OpenRouter and similar aggregators let you skip juggling consoles entirely. For Chinese vendors, the single most common mistake is registering on the wrong platform: domestic and international consoles, accounts, and endpoints are separate systems, so decide based on your location and billing currency before creating a key (see the Section 3 comparison table). And when even a cloud key is one dependency too many, a self-hosted Ollama/vLLM server β serving your own fine-tuned checkpoint β speaks the exact same OpenAI dialect. From there, the same OpenAI-compatible request shape serves nearly every provider on this list β which is exactly why one well-guarded key (or one aggregator key, or one localhost URL) is usually all a project needs.
API keys, consoles, and free tiers change frequently. Always confirm details against the provider's official documentation before production use.