How to use Vercel AI Gateway with Subconscious
Let your AI do the setup. Paste this into Claude Code, Codex, ChatGPT or any assistant.
Route my project's model calls to Subconscious through Vercel AI Gateway.
Subconscious is an inference provider for long-running agents. Gateways serve its models as one provider among many, under the gateway’s own API key and model IDs.
- API key: read it from the AI_GATEWAY_API_KEY environment variable. Never commit the key or paste it into project files. If it is not set, ask me to create one in Vercel AI Gateway.
Follow these steps. Run commands and edit files yourself. If I already have agent code, change its model setup to match the example instead of adding a new file.
1. Create an AI Gateway API key
In the Vercel dashboard, open AI Gateway, then API Keys, and create a key. Vercel shows it once, so copy it and export it.
```bash
export AI_GATEWAY_API_KEY="your_key"
```
2. Install the AI SDK
The AI SDK reads the key from the environment and sends model strings to AI Gateway.
```bash
npm install ai
```
3. Route the request to Subconscious
Pass the model ID and set `only` to `subconscious`. Without it, AI Gateway can send the request to any provider that serves the model. To confirm, `providerMetadata.gateway.routing.finalProvider` on the result reads `subconscious`.
```ts
import { generateText } from "ai";
const { text } = await generateText({
model: "zai/glm-5.3",
prompt: "Summarize the open issues in this repo.",
providerOptions: {
gateway: { only: ["subconscious"] },
},
});
console.log(text);
```
4. Or call the OpenAI compatible endpoint
Any OpenAI client works too. Point it at AI Gateway and send the same provider filter in the request body.
```bash
curl https://ai-gateway.vercel.sh/v1/chat/completions \
-H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai/glm-5.3",
"messages": [{ "role": "user", "content": "Hello" }],
"providerOptions": { "gateway": { "only": ["subconscious"] } }
}'
```
Full guide: https://www.subconscious.dev/integrations/gateways/vercel-ai-gateway.md
When you are done, confirm the gateway served the request from Subconscious, then summarize what you changed.To use Subconscious through Vercel AI Gateway, call zai/glm-5.3 or deepseek/deepseek-v4.1-flash-1017 with your AI Gateway API key and restrict routing to the subconscious provider. Requests then run on Subconscious and bill through your Vercel account, with no Subconscious key.
Last verified against the Vercel AI Gateway docs on
Before you start
- A Vercel account
- Node.js and npm, for the AI SDK example
Set up Vercel AI Gateway
Step 1: Create an AI Gateway API key
In the Vercel dashboard, open AI Gateway, then API Keys, and create a key. Vercel shows it once, so copy it and export it.
Terminalexport AI_GATEWAY_API_KEY="your_key"Step 2: Install the AI SDK
The AI SDK reads the key from the environment and sends model strings to AI Gateway.
Terminalnpm install aiStep 3: Route the request to Subconscious
Pass the model ID and set
onlytosubconscious. Without it, AI Gateway can send the request to any provider that serves the model. To confirm,providerMetadata.gateway.routing.finalProvideron the result readssubconscious.index.mtsimport { generateText } from "ai"; const { text } = await generateText({ model: "zai/glm-5.3", prompt: "Summarize the open issues in this repo.", providerOptions: { gateway: { only: ["subconscious"] }, }, }); console.log(text);Step 4: Or call the OpenAI compatible endpoint
Any OpenAI client works too. Point it at AI Gateway and send the same provider filter in the request body.
Terminalcurl https://ai-gateway.vercel.sh/v1/chat/completions \ -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "zai/glm-5.3", "messages": [{ "role": "user", "content": "Hello" }], "providerOptions": { "gateway": { "only": ["subconscious"] } } }'
Why route Vercel AI Gateway to Subconscious
- Keep your gateway
- Use the key, billing and fallbacks you already have. Subconscious is one more provider to route to.
- Long sessions stay fast
- 2x faster task completion on long tasks than standard open-model inference, especially past 200k tokens of context.
- Your data stays yours
- Subconscious does not record prompts, inputs or outputs, and nothing you send is used to train a model. Your gateway’s own data policy still applies.
Questions
- Which models does Subconscious serve on Vercel AI Gateway?
- GLM-5.3 (zai/glm-5.3) and DeepSeek V4.1 1017 (deepseek/deepseek-v4.1-flash-1017). Vercel lists both on its Subconscious provider page: https://vercel.com/ai-gateway/models/providers/subconscious
- Do I need a Subconscious account?
- No. With AI Gateway’s own credentials, Vercel bills you at the prices on its Subconscious provider page. Talk to us directly for higher rate limits or a dedicated deployment.
- Can I prefer Subconscious but fall back to other providers?
- Yes. Set order to ["subconscious"] instead of only. AI Gateway tries Subconscious first and moves to the next healthy provider if a request fails.
More gateways
See allLiquid Inference
An exchange where providers compete to serve each prompt at the lowest price.
RouterPlus
Routes each request to the model that scores best on your own evals.
Cloudflare AI Gateway
Coming soonA proxy for model calls with caching, rate limits, retries and logs.
OpenRouter
Coming soonOne API for hundreds of models, routed across providers by price and uptime.

Requesty
Coming soonOne OpenAI compatible endpoint with routing, fallbacks and caching.

Snowflake Cortex AI
Coming soonCall models from SQL, next to the data in your Snowflake account.