# AI models

One OpenAI-compatible API key for GPT, Claude, Gemini, Grok, DeepSeek, Qwen and hundreds more models, with streaming.

## How it works

Click Deploy on the AI card. You get two values, `AI_BASE_URL` and `AI_API_KEY`. Give them to any OpenAI client as its base URL and API key, then pick a model by name. You do not need accounts or keys with OpenAI, Anthropic, Google or anyone else.

- The API speaks OpenAI's Chat Completions format: messages, streaming, tools and function calling, JSON output and images all work as they do with OpenAI.
- Models are named by provider, such as `openai/gpt-5-mini`, `anthropic/claude-sonnet-4.5`, `google/gemini-2.5-flash`, `x-ai/grok-4`, `deepseek/deepseek-chat` or `qwen/qwen3-coder`. Every model and its price is listed under Models and prices below.
- Keep the key on your server. It is not meant for browser code.

## OpenAI SDK

*Streaming, from your server*

```ts
import OpenAI from "openai";

const ai = new OpenAI({
  baseURL: process.env.AI_BASE_URL,
  apiKey: process.env.AI_API_KEY,
});

const stream = await ai.chat.completions.create({
  model: "anthropic/claude-sonnet-4.5",
  messages: [{ role: "user", content: "Write a haiku about Postgres." }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
```

*Python*

```python
import os
from openai import OpenAI

ai = OpenAI(base_url=os.environ["AI_BASE_URL"], api_key=os.environ["AI_API_KEY"])
reply = ai.chat.completions.create(
    model="deepseek/deepseek-chat",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)
```

*curl*

```bash
curl "$AI_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $AI_API_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "openai/gpt-5-mini", "messages": [{"role": "user", "content": "Hello!"}]}'
```

## Agents and frameworks

Most non-OpenAI models only support Chat Completions, so tell agent frameworks to use it instead of OpenAI's Responses API.

*OpenAI Agents SDK (@openai/agents)*

```ts
import OpenAI from "openai";
import { Agent, run, setDefaultOpenAIClient, setOpenAIAPI, setTracingDisabled } from "@openai/agents";

setDefaultOpenAIClient(new OpenAI({ baseURL: process.env.AI_BASE_URL, apiKey: process.env.AI_API_KEY }));
setOpenAIAPI("chat_completions");
setTracingDisabled(true); // Tracing uploads to OpenAI and needs an OpenAI key.

const agent = new Agent({
  name: "Support",
  instructions: "Answer questions about the user's order.",
  model: "google/gemini-2.5-flash",
});
const result = await run(agent, "Where is my order?");
console.log(result.finalOutput);
```

*Vercel AI SDK*

```ts
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";

const models = createOpenAICompatible({
  name: "cloudhike",
  baseURL: process.env.AI_BASE_URL!,
  apiKey: process.env.AI_API_KEY,
});

const result = streamText({ model: models("openai/gpt-5-mini"), prompt: "Hello!" });
return result.toTextStreamResponse(); // In a Next.js route handler
```

*LangChain*

```ts
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "qwen/qwen3-coder",
  apiKey: process.env.AI_API_KEY,
  configuration: { baseURL: process.env.AI_BASE_URL },
});
```

## Models and prices

Every model you can call, with what you pay per million tokens: the provider's own price plus 5%. Use the id in the second line as `model`.

The full list of models with their current prices is at https://cloudhike.dev/docs/ai#models, and `GET AI_BASE_URL/models` returns it as JSON.

The same list, as JSON, from your server. Each model has `pricing.input_per_million_usd` and `pricing.output_per_million_usd`. Free model variants (ids ending in `:free`) are not available.

```bash
curl "$AI_BASE_URL/models" -H "Authorization: Bearer $AI_API_KEY"
```

## Pricing and limits

Every request is charged at the price its provider charges, plus 5%, from your credits. The cost is what the provider reports for that request, so cached prompts and reasoning tokens are counted the way the provider counts them. Usage is charged every hour and shows as AI models on Credits & Billing.

|  | Free | Pro | Scale |
| --- | --- | --- | --- |
| Requests per minute | 20 | 300 | 1,000 |
| Most spent on models per month | $2.00 a month | Your credits and spend cap | Your credits and spend cap |

- Requests are refused with 402 once the account is out of credits or reaches its spend cap, and with 429 over a limit. Errors use OpenAI's shape, so SDKs show the message.
- A stream you stop early is charged for what was generated until then.
- Prompts and answers are never stored. Each request's model, token counts and cost are kept for billing.

## Use with AI

Let your coding agent add AI features with CloudHike.dev models.

```text
Read https://cloudhike.dev/docs/md/ai. Add AI to this app with CloudHike.dev AI models: create an OpenAI client from AI_BASE_URL and AI_API_KEY in server code only, stream the replies to the UI, and pick a model from GET AI_BASE_URL/models.
```
