When you host Next AI Draw.io yourself, environment variables choose the AI provider and the model. This page shows the variables for each provider, how to offer several models to all users, and how to add a new provider to the code.
Get started
- Copy
env.exampleto.env.local. - Set the API key of the provider you chose.
- Set
AI_MODELto the model you want. - Run
npm run dev.
Set up each provider
OpenAI
OPENAI_API_KEY=your_api_key
AI_MODEL=gpt-4oOptionally, set a custom endpoint for an OpenAI-compatible service:
OPENAI_BASE_URL=https://your-custom-endpoint/v1LM Studio and other local OpenAI-compatible servers work the same way. Set the base URL to http://localhost:1234/v1 (LM Studio's default port) and use any non-empty API key, such as lm-studio. This works with the environment variables above and in the Models tab of Settings.
Anthropic
ANTHROPIC_API_KEY=your_api_key
AI_MODEL=claude-sonnet-4-5-20250929You can also sign in with a Bearer token, for example when you go through a gateway that issues OAuth-style tokens:
ANTHROPIC_AUTH_TOKEN=your_auth_token
AI_MODEL=claude-sonnet-4-5-20250929ANTHROPIC_API_KEY is sent as the x-api-key header, and ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer <token>. The two cannot be used together, so set only one.
Optionally, set a custom endpoint:
ANTHROPIC_BASE_URL=https://your-custom-endpointGoogle Gemini
GOOGLE_GENERATIVE_AI_API_KEY=your_api_key
AI_MODEL=gemini-2.0-flashOptionally, set a custom endpoint:
GOOGLE_BASE_URL=https://your-custom-endpointDeepSeek
DEEPSEEK_API_KEY=your_api_key
AI_MODEL=deepseek-chatOptionally, set a custom endpoint:
DEEPSEEK_BASE_URL=https://your-custom-endpointQwen (Alibaba Cloud)
QWEN_API_KEY=your_api_key
AI_MODEL=qwen-turboOptionally, set a custom endpoint:
QWEN_BASE_URL=https://your-custom-endpointDoubao (ByteDance Volcengine)
DOUBAO_API_KEY=your_api_key
AI_MODEL=doubao-seed-1-8-251228 # or other Doubao modelGLM (Zhipu AI)
GLM_API_KEY=your_api_key
AI_MODEL=glm-4Optionally, set a custom endpoint:
GLM_BASE_URL=https://your-custom-endpointKimi (Moonshot AI)
KIMI_API_KEY=your_api_key
AI_MODEL=kimi-latestOptionally, set a custom endpoint:
KIMI_BASE_URL=https://your-custom-endpointMiniMax
MiniMax supports two API formats:
| Format | Endpoint | Notes |
|---|---|---|
| Anthropic-compatible | /anthropic | Recommended. Supports interleaved thinking, where the model can think between tool calls |
| OpenAI-compatible | /v1 | The standard OpenAI chat completions format |
MINIMAX_API_KEY=your_api_key
AI_MODEL=MiniMax-M3Optional settings:
# China mainland, Anthropic-compatible (default)
MINIMAX_BASE_URL=https://api.minimaxi.com/anthropic
# China mainland, OpenAI-compatible
MINIMAX_BASE_URL=https://api.minimaxi.com/v1
# International, Anthropic-compatible
MINIMAX_BASE_URL=https://api.minimax.io/anthropic
# International, OpenAI-compatible
MINIMAX_BASE_URL=https://api.minimax.io/v1MiMo (Xiaomi)
MIMO_API_KEY=your_api_key
AI_MODEL=mimo-v2.5-proOptionally, set a custom endpoint. Token Plan subscribers should set their dedicated base URL:
MIMO_BASE_URL=https://token-plan-cn.xiaomimimo.com/v1OpenRouter
OPENROUTER_API_KEY=your_api_key
AI_MODEL=anthropic/claude-sonnet-4Optionally, set a custom endpoint:
OPENROUTER_BASE_URL=https://your-custom-endpointAIHubMix
AIHubMix gives you Claude, GPT, Gemini, DeepSeek and other models with one API key.
AIHUBMIX_API_KEY=your_api_key
AI_MODEL=claude-sonnet-4-5-20250929Optionally, set a custom endpoint:
AIHUBMIX_BASE_URL=https://aihubmix.com/v1SiliconFlow (OpenAI-compatible)
SILICONFLOW_API_KEY=your_api_key
AI_MODEL=deepseek-ai/DeepSeek-V3 # example; use any SiliconFlow model idWithout a base URL, the app uses https://api.siliconflow.cn/v1, the endpoint for keys from cloud.siliconflow.cn. If your key comes from the international site, cloud.siliconflow.com, set the .com endpoint:
SILICONFLOW_BASE_URL=https://api.siliconflow.com/v1ModelScope
MODELSCOPE_API_KEY=your_api_key
AI_MODEL=Qwen/Qwen3-235B-A22B-Instruct-2507Optionally, set a custom endpoint:
MODELSCOPE_BASE_URL=https://your-custom-endpointNovita AI
NOVITA_API_KEY=your_api_key
AI_MODEL=deepseek/deepseek-v4-proOptionally, set a custom endpoint. Without one, https://api.novita.ai/openai is used:
NOVITA_BASE_URL=https://your-custom-endpointAtlas Cloud
ATLASCLOUD_API_KEY=your_api_key
AI_MODEL=your_model_idThe app has no built-in model list for Atlas Cloud. In the Models tab of Settings, it loads the list from Atlas Cloud with your key.
Optionally, set a custom endpoint. Without one, https://api.atlascloud.ai/v1 is used:
ATLASCLOUD_BASE_URL=https://your-custom-endpointQiniu (Qiniu Cloud)
QINIU_API_KEY=your_api_key
AI_MODEL=your_model_idOptionally, set a custom endpoint:
QINIU_BASE_URL=https://your-custom-endpointVercel AI Gateway
Vercel AI Gateway gives you many AI providers through one API key. Signing in is simpler, and you can switch providers without managing several API keys.
With the gateway that Vercel hosts:
AI_GATEWAY_API_KEY=your_gateway_api_key
AI_MODEL=openai/gpt-4oWith a custom gateway URL, for local development or a self-hosted gateway:
AI_GATEWAY_API_KEY=your_custom_api_key
AI_GATEWAY_BASE_URL=https://your-custom-gateway.com/v1/ai
AI_MODEL=openai/gpt-4oModel ids take the form provider/model:
AI_MODEL | Model |
|---|---|
openai/gpt-4o | OpenAI GPT-4o |
anthropic/claude-sonnet-4-5 | Anthropic Claude Sonnet 4.5 |
google/gemini-2.0-flash | Google Gemini 2.0 Flash |
If AI_GATEWAY_BASE_URL is not set, the default Vercel Gateway URL (https://ai-gateway.vercel.sh/v1/ai) is used. A custom base URL is useful for:
- Local development with your own Gateway instance
- Self-hosted AI Gateway deployments
- Enterprise proxy setups
When you use a custom base URL, you must also set AI_GATEWAY_API_KEY.
Get your API key from the Vercel AI Gateway dashboard.
Amazon Bedrock
AWS_REGION=us-west-2
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AI_MODEL=global.anthropic.claude-sonnet-5-5Recent Claude models answer only through an inference profile id. This id starts with a region prefix such as global. or us.. The plain id (anthropic.claude-sonnet-5-5) fails with "on-demand throughput isn't supported".
On AWS (Lambda, or EC2 with an IAM role), the credentials come from the IAM role automatically.
Google Vertex AI
Google Vertex AI is Google Cloud's service for companies, with enterprise features and data residency (your data stays in the region you choose). Its Express Mode signs in with a plain API key, so it also works on edge runtimes such as Vercel and Cloudflare.
GOOGLE_VERTEX_API_KEY=your_api_key
AI_MODEL=gemini-2.0-flashOptionally, set a custom endpoint:
GOOGLE_VERTEX_BASE_URL=https://your-custom-endpointAzure OpenAI
Azure needs either your resource name or your endpoint URL. Set one of the two. If you set both, AZURE_BASE_URL is used.
With the resource name:
AZURE_API_KEY=your_api_key
AZURE_RESOURCE_NAME=your-resource-name # Your Azure resource name
AI_MODEL=your-deployment-nameOr with the endpoint URL in place of the resource name:
AZURE_API_KEY=your_api_key
AZURE_BASE_URL=https://your-resource.openai.azure.com/openai # In place of AZURE_RESOURCE_NAME
AI_MODEL=your-deployment-nameOptionally, set the reasoning options:
AZURE_REASONING_EFFORT=low # Optional: low, medium, high
AZURE_REASONING_SUMMARY=detailed # Optional: none, brief, detailedEdgeOne Pages (Tencent Cloud)
When you deploy the app on Tencent EdgeOne Pages, it can use the site's own Edge AI function at /api/edgeai. This needs no API key and no base URL. With no key to detect, the server cannot pick this provider by itself, so set AI_PROVIDER:
AI_PROVIDER=edgeone
AI_MODEL=@tx/deepseek-ai/deepseek-v32The function accepts @tx/deepseek-ai/deepseek-v32, @tx/deepseek-ai/deepseek-r1-0528 and @tx/deepseek-ai/deepseek-v3-0324. If you set ACCESS_CODE_LIST, the function checks the access code too.
Ollama (local)
AI_PROVIDER=ollama
AI_MODEL=llama3.2Optionally, set a custom URL:
OLLAMA_BASE_URL=http://localhost:11434/apiSGLang
SGLANG_API_KEY=your_api_key
AI_MODEL=your_model_idOptionally, set a custom endpoint:
SGLANG_BASE_URL=https://your-custom-endpoint/v1Any other OpenAI-compatible API (custom)
For a server not listed above, such as vLLM, LM Studio, LiteLLM or an API gateway, pick OpenAI-compatible in Settings and enter its base URL and a key. If the server ignores keys, any non-empty value works.
The app merges several system messages into one, as open-source chat templates expect, and splits <think> reasoning from the reply.
CUSTOM_API_KEY=your_api_key
CUSTOM_BASE_URL=http://127.0.0.1:8000/v1
AI_MODEL=your_model_idHow the server picks the provider
If you set the API key of only one provider, the server detects that provider and uses it. You do not need to set AI_PROVIDER.
If you set API keys for several providers, you must set AI_PROVIDER:
AI_PROVIDER=google # or: openai, anthropic, google, vertexai, azure, bedrock, ollama, openrouter, aihubmix, deepseek, siliconflow, sglang, gateway, edgeone, doubao, modelscope, glm, qwen, qiniu, kimi, minimax, novita, mimo, atlascloud, customOffer several models to all users
As an administrator, you can set up several models on the server. All users can then use them without an API key of their own. Without this config, the app uses the AI_PROVIDER and AI_MODEL variables.
You can set it up in three ways.
Put the config in an environment variable
This way is recommended for cloud deployments. Set AI_MODELS_CONFIG to a JSON string:
AI_MODELS_CONFIG='{"providers":[{"name":"OpenAI","provider":"openai","models":["gpt-4o"],"default":true}]}'Use a config file
Create an ai-models.json file in the project root. To keep it somewhere else, set AI_MODELS_CONFIG_PATH to its location.
List several models in AI_MODEL
This is a quick setup for a single provider. If you only need several models from one provider, list them in AI_MODEL, separated by commas. The first model is the default.
AI_PROVIDER=doubao
AI_MODEL=doubao-seed-1-8-251228,doubao-seed-1-6-flash-250828,doubao-seed-1-6-251015This is a short way to write the same ai-models.json. For several providers, or for your own apiKeyEnv and baseUrlEnv, use the environment variable or the config file.
Example
{
"providers": [
{
"name": "OpenAI Production",
"provider": "openai",
"models": ["gpt-4o", "gpt-4o-mini"],
"default": true
},
{
"name": "Custom DeepSeek",
"provider": "deepseek",
"models": ["deepseek-chat"],
"apiKeyEnv": "MY_DEEPSEEK_KEY",
"baseUrlEnv": "MY_DEEPSEEK_URL"
}
]
}Fields
| Field | Required | What it does |
|---|---|---|
name | Yes | The display name. Several configs can use the same provider |
provider | Yes | The provider type (openai, anthropic, google, bedrock and so on) |
models | Yes | The list of model IDs |
default | No | true selects this provider's first model as the default |
apiKeyEnv | No | The name of a custom API key variable. Without it, the provider's standard variable is used, such as OPENAI_API_KEY. It can also be an array of variable names: each request picks one that has a value at random, which spreads the load over several keys |
baseUrlEnv | No | The name of a custom base URL variable |
Keys and names
- API keys and credentials come from environment variables. By default the standard names are used, such as
OPENAI_API_KEY. WithapiKeyEnvyou can use names of your own. - With
name, one provider can have several configs. For example, "OpenAI Production" and "OpenAI Staging" can both useprovider: "openai"with differentapiKeyEnvvalues.
Choose a model
To draw, the model writes long draw.io XML that must follow a strict format, so this task needs a very capable model.
Recommended models: Claude Sonnet 4.5 or Opus 4.5.
Ollama is supported as a provider. For this task, it is usually practical only when you run a strong model such as DeepSeek R1 or Qwen3-235B locally.
| What you want | What to use |
|---|---|
| The best experience | A model that can read images (GPT-4o, Claude, Gemini), for turning images into diagrams |
| A low cost | DeepSeek, which has competitive prices |
| Privacy | Ollama, fully local and offline. It needs powerful hardware |
| Flexibility | OpenRouter, which gives you many models through one API |
Set the temperature
Setting the temperature is optional. Set it with an environment variable:
TEMPERATURE=0 # More deterministic output (recommended for diagrams)Important: leave TEMPERATURE unset for models that do not support a temperature setting, such as:
- GPT-5.1 and other reasoning models
- Some specialized models
When it is unset, the model uses its default behavior.
Add a new provider
Everything about a provider is in one record in lib/providers.ts:
- which AI SDK runs it (
sdk) - what it signs in with (
credential) - the prefix of its
<PREFIX>_API_KEYand<PREFIX>_BASE_URLvariables (envPrefix) - its official URL
- its group in the provider picker
- optional notes
The settings screen, the connection test, the chat route and the admin panel all read this record. To add an OpenAI-compatible provider:
-
Add a record to
lib/providers.ts, for example:acme: { label: "Acme AI", sdk: "openai-compatible", credential: "apiKey", group: "aggregators", envPrefix: "ACME", defaultBaseUrl: "https://api.acme.example/v1", apiKeyUrl: "https://acme.example/keys", modelList: "openai", },If the provider needs a hint under its base URL field, or a note in the picker, give it a
baseUrlHintornoteobject with all four UI languages (en,zh,ja,zh-Hant). A provider that cannot list its models online gets a shortmodelslist in place ofmodelList. -
Add
ACME_API_KEYandACME_BASE_URLtoenv.example. A unit test checks that the variables of every record appear there. -
Add a section for it to this page in
docs/en,docs/cn,docs/twanddocs/ja. -
Add it to the two lists at the top of
tests/unit/provider-matrix.test.ts(MATRIX_PROVIDERSandMATRIX_MODEL_IDS). Then regenerate the behavior snapshot withnpx vitest run tests/unit/provider-matrix.test.ts -u. The new rows belong to the new provider, and the existing rows must not change. -
Add it to
tests/unit/providers.test.tstoo. That file spells out the groups of the picker and the sets of providers that change what the server does (auto-detection, single system message). -
Update the provider count in the three READMEs and the
AI_PROVIDERlist on this page.