inference.eu

Frameworks · Mastra

Use Mastra with open-source models hosted in the EU

Mastra is a TypeScript framework for building AI agents, workflows and RAG pipelines. Its model router accepts any OpenAI-compatible endpoint through a `url` setting, so your agents can run on open-weight models at inference.eu, processed in European data centres.

  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 project's .env file.

  2. 2

    In your agent definition, set model to an object with id, url and apiKey instead of a model string.

  3. 3

    Use inference-eu/ followed by the model id as id, the inference.eu base URL as url and process.env.INFERENCE_EU_API_KEY as apiKey.

  4. 4

    Register the agent in your Mastra instance as usual.

  5. 5

    Start mastra dev and send the agent a message in Studio to confirm the connection.

src/mastra/agents/support-agent.ts
import { Agent } from "@mastra/core/agent";

export const supportAgent = new Agent({
  id: "support-agent",
  name: "Support agent",
  instructions: "You answer customer questions using the tools provided.",
  model: {
    id: "inference-eu/kimi-k3",
    url: "https://api.inference.eu/v1",
    apiKey: process.env.INFERENCE_EU_API_KEY,
  },
});

What Mastra is

Mastra is an open-source TypeScript framework from the team behind Gatsby. It provides agents with tools and memory, graph-based workflows with suspend and resume, RAG helpers, evaluations and a local Studio for testing. Mastra apps run in Node.js and deploy to servers, serverless platforms or inside existing web frameworks.

Models are chosen through Mastra's model router. Besides the built-in providers, it accepts a custom OpenAI-compatible endpoint by passing url alongside the model id, which is the documented way to connect a service such as inference.eu.

How the configuration works

Instead of a string like "openai/...", set model to an object. id uses the form provider/model; with inference-eu/kimi-k3, Mastra sends the bare model id kimi-k3 to the endpoint. url is the inference.eu base URL ending in /v1, never the full chat completions path. apiKey is sent as a bearer token.

Custom URLs use the Chat Completions API by default, which is what you want for inference.eu. If you prefer, you can also create a provider with createOpenAICompatible from the AI SDK and pass the resulting model to the agent; Mastra accepts AI SDK models directly.

Which models to choose

Mastra agents call tools and often run inside multi-step workflows, so models with dependable tool calling work best. kimi-k3 and glm-5.3 are strong defaults for support, research and operations agents that plan and use several tools.

For agents that write or review code, use qwen3-coder-480b-a35b-instruct. For quick classification, routing or structured extraction steps inside a workflow, gpt-oss-120b keeps latency low. Each agent and workflow step can use its own model object, and Mastra's model fallbacks let you list a second inference.eu model to try if the first fails.

Troubleshooting

A 401 error means INFERENCE_EU_API_KEY is not set where the agent runs; check the .env file locally and the environment settings of your deployment. A 404 usually means url includes /chat/completions or another extra path. Use the base URL ending in /v1.

"Model not found" means the part of id after inference-eu/ does not match an inference.eu model id. If structured output fails, simplify the Zod schema. If an agent ignores its tools, choose a model with stronger tool calling. Do not set api: "responses" for inference.eu; keep the default Chat Completions path.

Keeping data in the EU

With the model pointed at inference.eu, the messages, memory excerpts and tool results your agents send are 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.

Mastra itself only calls the services you configure. Memory storage, vector databases and observability exporters each hold data too, so choose EU-hosted or self-hosted options for them. Deploy your Mastra server in an EU region so that requests are not handled elsewhere before they reach inference.eu.

Mastra: common questions

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

Ask a question

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