---
title: "OpenAI-compatible APIs"
description: "Use GistUI with the Vercel AI Gateway, OpenRouter, Groq, Together, Ollama, vLLM and any other API that speaks OpenAI's Chat Completions format."
---

> Documentation Index
> Fetch the complete documentation index at: https://gistui.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI-compatible APIs

Most gateways and model servers accept OpenAI's Chat Completions request and return its streaming format. For all of them the code is the same; only the URL, the key and the model id change.

```ts title="api/answer.ts"
import { prompt } from "@gistui/catalog";
import { textDeltas, toReadable } from "@gistui/server";

const URL = "https://ai-gateway.vercel.sh/v1/chat/completions";
const KEY = process.env.AI_GATEWAY_API_KEY;
const MODEL = "openai/gpt-oss-120b";

export async function POST(req: Request) {
  const { messages } = await req.json();
  const res = await fetch(URL, {
    method: "POST",
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({
      model: MODEL,
      stream: true,
      messages: [{ role: "system", content: prompt().text }, ...messages],
    }),
  });
  if (!res.ok) return new Response(await res.text(), { status: res.status });
  return new Response(toReadable(textDeltas(res, "openai")));
}
```

## Endpoints

| Service | URL | Model id looks like |
|---|---|---|
| Vercel AI Gateway | `https://ai-gateway.vercel.sh/v1/chat/completions` | `openai/gpt-oss-120b` |
| OpenRouter | `https://openrouter.ai/api/v1/chat/completions` | `google/gemini-3.7-flash` |
| Groq | `https://api.groq.com/openai/v1/chat/completions` | `openai/gpt-oss-120b` |
| Together | `https://api.together.xyz/v1/chat/completions` | the provider's model name |
| Ollama (local) | `http://localhost:11434/v1/chat/completions` | `qwen3:8b` |
| vLLM, LM Studio, llama.cpp | your server's `/v1/chat/completions` | whatever you loaded |

Model ids change often: check the service's own list.

> **Note**
>
> GistUI's benchmark run went through the Vercel AI Gateway with exactly this code path. See [Benchmarks](/docs/reference/benchmarks/).

## Local models

A local server needs no key. Small models follow the prompt less exactly; two things help.

- **A smaller prompt.** Leave out the groups you do not need: `prompt({ groups: ["Layout", "Content", "Data"] })`.
- **Autofix.** It is on by default in every renderer and repairs most slips in code. See [Autofix and repair](/docs/guides/autofix/).

## In a chat

The `openai()` adapter of `@gistui/chat` speaks to any of these through your endpoint:

```ts
import { createChat, openai } from "@gistui/chat";

const store = createChat({ adapter: openai({ model: "openai/gpt-oss-120b", url: "/api/chat" }) });
```

Source: https://gistui.com/docs/models/openai-compatible/index.mdx
