---
title: "Vercel AI SDK with EU-hosted models · Setup guide"
description: "Use the Vercel AI SDK's OpenAI-compatible provider to call open-weight models processed in EU data centres from Next.js, Node.js or edge apps."
canonical: "https://inference.eu/integrations/vercel-ai-sdk/"
language: "en"
---

SDKs · Vercel AI SDK

# Use the Vercel AI SDK with open-source models hosted in the EU

The Vercel AI SDK is a TypeScript toolkit for building AI features into web apps and back ends. Its OpenAI-compatible provider connects to inference.eu in a few lines, so \`generateText\`, \`streamText\`, tools and structured output all run on open-weight models processed in European data centres.

[Contact sales](https://inference.eu/contact/)[Setup](#setup)

1.  01API format: OpenAI
2.  02EU data centres
3.  03Covered by one DPA

## Set it up in a few minutes

1.  1

    Create an API key in your inference.eu account and add `INFERENCE_EU_API_KEY` to your server environment, for example `.env.local`.

2.  2

    Install the packages with `npm install ai @ai-sdk/openai-compatible`.

3.  3

    Create a provider with `createOpenAICompatible`, setting `name`, `baseURL` to the inference.eu base URL, `apiKey` and `includeUsage`.

4.  4

    Pass `inferenceEu("<model id>")` as the `model` to `generateText`, `streamText` or `generateObject`.

5.  5

    Run a short request on the server to confirm the connection before wiring it into your UI.

lib/inference-eu.ts

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

export const inferenceEu = createOpenAICompatible({
  name: "inference-eu",
  baseURL: "https://api.inference.eu/v1",
  apiKey: process.env.INFERENCE_EU_API_KEY,
  includeUsage: true,
});

const { text } = await generateText({
  model: inferenceEu("gpt-oss-120b"),
  prompt: "Summarise GDPR Article 28 in two sentences.",
});
console.log(text);
```

## What the Vercel AI SDK is

The AI SDK is an open-source TypeScript library from Vercel. It gives you one API for text generation, streaming, tool calls, structured output and agents across many model providers, plus UI hooks such as `useChat` for React, Svelte and Vue. It runs in Node.js, serverless functions and edge runtimes.

Providers are separate packages. The `@ai-sdk/openai-compatible` package works with any API that implements the OpenAI format, which is the recommended way to connect inference.eu. You keep the same AI SDK calls and swap only the provider instance.

## How the configuration works

`createOpenAICompatible` returns a provider function. `name` labels it in errors and telemetry, `baseURL` is the inference.eu base URL ending in `/v1`, and `apiKey` is sent as a bearer token. `includeUsage: true` asks for token counts in streamed responses so that `usage` is filled in after `streamText` finishes.

Call the provider with a model id to get a model, for example `inferenceEu("qwen3-coder-480b-a35b-instruct")`. Keep the provider in a server-only module: the key must never reach the browser. Route handlers, server actions and API routes then import it and stream results to the client through `useChat` or your own UI.

## Which models to choose

For chat features, summaries and extraction, `gpt-oss-120b` is a fast default that keeps streaming responsive in the UI. For agents built with tools and `stopWhen`, choose a model with dependable tool calling such as `qwen3-coder-480b-a35b-instruct`, `glm-5.3` or `kimi-k3`.

`glm-5.3` and `kimi-k3` also suit long documents and multi-step reasoning. If you use `generateObject` with a Zod schema, set `supportsStructuredOutputs: true` on the provider only after testing that the chosen model returns valid JSON reliably; otherwise the SDK falls back to instructing the model and validates the result.

## Troubleshooting

A 401 error means `INFERENCE_EU_API_KEY` is not set in the runtime that executes the call. Serverless and edge deployments need the variable configured in the hosting environment, not only in `.env.local`. A 404 usually means `baseURL` has an extra path.

"Model not found" means the id passed to the provider differs from the inference.eu id. If `usage` is empty after streaming, add `includeUsage: true`. If tool calls are ignored, check the model supports tools. Do not use the `@ai-sdk/openai` package for this: it targets OpenAI's Responses API by default, while the compatible provider uses Chat Completions.

## Keeping data in the EU

With the provider pointed at inference.eu, every prompt and completion your app sends is processed in EU data centres and never used for training. We sign a data processing agreement under Article 28 GDPR, publish our subprocessor list and bill in euros.

The AI SDK itself only calls the provider you configure. Your hosting region matters too: run route handlers and functions in an EU region so that prompts are not handled by servers elsewhere before they reach us. If you enable telemetry with OpenTelemetry, check where your tracing backend stores prompt and response attributes.

## Vercel AI SDK

Category

SDKs

Maker

Vercel

API format

OpenAI

Processing

EU data centres

Website

[ai-sdk.dev](https://ai-sdk.dev/)

Documentation

[ai-sdk.dev](https://ai-sdk.dev/providers/openai-compatible-providers)

## Vercel AI SDK: common questions

The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.

Install \`@ai-sdk/openai-compatible\` and call \`createOpenAICompatible\` with \`name\`, \`baseURL\` and \`apiKey\`. The returned function creates models by id, which you pass to \`generateText\`, \`streamText\` or any other AI SDK call in your app.

Use \`@ai-sdk/openai-compatible\`. It talks to Chat Completions, which inference.eu serves for every model. The \`@ai-sdk/openai\` provider is tuned for OpenAI's own platform and uses the Responses API by default, which is a different request format.

Use \`gpt-oss-120b\` for fast chat and extraction, \`qwen3-coder-480b-a35b-instruct\` for code and tool-heavy agents, and \`glm-5.3\` or \`kimi-k3\` for long documents and multi-step reasoning. Changing the model is a one-line edit.

Yes. \`streamText\` streams tokens from inference.eu as usual, and \`toUIMessageStreamResponse\` pipes them into \`useChat\`. Set \`includeUsage: true\` on the provider so token counts are available once the stream finishes, for logging or quotas.

Yes. Define tools with Zod schemas and pass them to \`generateText\` or \`streamText\`, using \`stopWhen\` for multi-step loops. Choose a model with dependable tool calling, such as Qwen3 Coder 480B, GLM-5.3 or Kimi K3.

Yes. The SDK sends your schema and validates the response. Set \`supportsStructuredOutputs: true\` on the provider only after testing that your chosen model follows JSON schemas reliably, so that the SDK can use native structured output.

The deployed runtime does not have \`INFERENCE\_EU\_API\_KEY\`. Add the variable to your hosting project's environment settings for each environment, redeploy, and make sure the provider module runs on the server, not in the browser.

Yes. The compatible provider uses the standard \`fetch\` API and works in edge runtimes. Choose an EU region for the function where your platform allows it, so that requests are handled in Europe before reaching inference.eu.

Yes, and you should. Create the provider in a server-only module and call it from route handlers or server actions. The client uses \`useChat\` against your own endpoint and never sees the inference.eu key.

No. The SDK is a library that calls the provider you configure directly. Prompts only go elsewhere if you add services such as telemetry exporters or a gateway. Your hosting platform runs your code, so choose its region with care.

[Ask a question](https://inference.eu/contact/)

## Related

[All integrations](https://inference.eu/integrations/)

-   [OpenAI SDK (Python and JavaScript)Point the official OpenAI Python or JavaScript SDK at inference.eu with base\_url and an API key, and call open-weight models processed in the EU.SDKs](https://inference.eu/integrations/openai-sdk/)
-   [MastraPoint Mastra agents and workflows at inference.eu with a custom model URL and run them on open-weight models processed in EU data centres.Frameworks](https://inference.eu/integrations/mastra/)
-   [LangChainConnect LangChain's ChatOpenAI to inference.eu with base\_url and run chains, agents and LangGraph workflows on open-weight models processed in the EU.Frameworks](https://inference.eu/integrations/langchain/)

## Move your AI workloads to EU infrastructure

Tell us which models you use and roughly how much traffic you have. We reply within one working day with pricing and next steps.

-   Reply within one working day
-   Pricing for your volume
-   DPA ready to sign
