# Use any SDK

Point an OpenAI, Anthropic, Google or Vercel AI SDK, or Veryfront Code, at the [AI Gateway](/docs/ai-gateway.md).

## Before you start

You need an [API key](/docs/authentication/api-keys.md) with **Write** ticked, in your shell: `export VERYFRONT_API_KEY=<your key>`.

## Point your SDK at the gateway

**Code**

**OpenAI SDK**

1. Install the SDK:

```bash
npm install openai
```

2. Create the file:

```js title="chat.mjs"
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.veryfront.com/ai/v1",
  apiKey: process.env.VERYFRONT_API_KEY,
});

const response = await client.chat.completions.create({
  model: "openai/gpt-5-nano",
  messages: [{ role: "user", content: "Reply with gateway connected." }],
});
console.log(response.choices[0].message.content);
```

3. Run `node chat.mjs`. You should now see it print "gateway connected".

**Anthropic SDK**

1. Install the SDK:

```bash
npm install @anthropic-ai/sdk
```

2. Create the file:

```js title="chat.mjs"
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.veryfront.com/ai",
  apiKey: process.env.VERYFRONT_API_KEY,
});

const message = await client.messages.create({
  model: "anthropic/claude-haiku-4-5-20251001",
  max_tokens: 256,
  messages: [{ role: "user", content: "Reply with gateway connected." }],
});
console.log(message.content[0].text);
```

3. Run `node chat.mjs`. You should now see it print "gateway connected".

**Google Gen AI SDK**

1. Install the SDK:

```bash
npm install @google/genai
```

2. Create the file:

```js title="chat.mjs"
import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({
  apiKey: process.env.VERYFRONT_API_KEY,
  httpOptions: { baseUrl: "https://api.veryfront.com/ai", apiVersion: "v1beta" },
});

const response = await client.models.generateContent({
  model: "google/gemini-2.5-flash",
  contents: "Reply with gateway connected.",
});
console.log(response.text);
```

3. Run `node chat.mjs`. You should now see it print "gateway connected".

**Vercel AI SDK**

1. Install the SDK:

```bash
npm install ai @ai-sdk/openai
```

2. Create the file:

```js title="chat.mjs"
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const gateway = createOpenAI({
  baseURL: "https://api.veryfront.com/ai/v1",
  apiKey: process.env.VERYFRONT_API_KEY,
});

const result = await generateText({
  model: gateway.responses("openai/gpt-5-nano"),
  prompt: "Reply with gateway connected.",
});
console.log(result.text);
```

3. Run `node chat.mjs`. You should now see it print "gateway connected".

**Veryfront Code**

1. Sign in with the Veryfront CLI in your project:

```bash
npx veryfront@latest login
```

2. Name a gateway model in an agent:

```ts title="agents/assistant.ts"
import { agent } from "veryfront/agent";

export default agent({
  id: "assistant",
  model: "openai/gpt-5-nano",
  system: "You are a helpful assistant.",
});
```

3. Run `npm run dev`.
4. Open [localhost:3000](http://localhost:3000).
5. Ask "Reply with gateway connected." You should now see it reply "gateway connected".

**API**

1. Send a chat completion with your key:

```bash
curl https://api.veryfront.com/ai/v1/chat/completions \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "messages": [{ "role": "user", "content": "Reply with gateway connected." }]
  }'
```

2. Read `choices[0].message.content`. You should now see "gateway connected".

### Try it in a sandbox

```playground
check: curl https://api.veryfront.com/ai/v1/chat/completions -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "model": "openai/gpt-5-nano", "messages": [{ "role": "user", "content": "Reply with gateway connected." }] }'
expect: gateway connected
```

## Pick a model

Every call names a model as `vendor/model`. List what your key can call:

```bash
curl https://api.veryfront.com/ai/models -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

Each entry in `deployments` names its model in `model.id` and its route in `routing.surface`.

Or browse them on the [AI Gateway](/ai-gateway) page, or in Studio's [**Building blocks** > **Models**](/docs/agents/project-models.md).

## Troubleshooting

**If you see "No deployment of model … speaks the openai chat-completions protocol natively"**, the model is on another route. Call Claude with the Anthropic SDK, Gemini with Google's.

## Next steps

* [Use your own provider key](/docs/ai-gateway/provider-keys.md)
* [See what a project costs](/docs/observability/project-analytics.md)
