Mastra Integration

AVELIN API is compatible with Mastra — Open-source TypeScript framework for building AI-powered apps and agents with first-class support for tool use and structured output.

Mastra is the TypeScript-native AI framework — built from the ground up for developers who live in TypeScript. Its killer feature is first-class TypeScript support with built-in tool use, structured output, and agent orchestration. While other frameworks bolt TypeScript types onto Python-first designs, Mastra's entire API is designed for type safety: your tools, schemas, and agent workflows get full IntelliSense, compile-time validation, and zero runtime surprises.

Built for TypeScript/Node.js developers who want production-grade AI infrastructure without leaving their ecosystem. Mastra handles the hard parts — retries, streaming, tool calling, multi-agent coordination — while you write clean, typed code. Pair with AVELIN's OpenAI-compatible endpoint for a fully typed AI stack.

Why AVELIN + Mastra? Build production-grade AI applications with AVELIN's governed API, automatic failover, and 9 specialized models through a single endpoint.


Quick Setup

Step 1: Get your AVELIN API key

Sign up at avelin.ai and generate an API key. It will look like sk-ave...xxxx.

Step 2: Install Mastra

Refer to the Mastra documentation for installation instructions.

Step 3: Configure AVELIN

Set AVELIN as your LLM provider via environment variables:

export OPENAI_API_BASE=https://api.avelin.ai/v1
export OPENAI_API_KEY=sk-avelin-YOUR_KEY

API Reference

EndpointURL
OpenAI-compatiblehttps://api.avelin.ai/v1
Anthropic-compatiblehttps://api.avelin.ai

Use caseModelWhy
General purposeavelin-proBalanced quality and speed
Complex reasoningavelin-ultraFlagship capabilities
Code generationavelin-coding-pro1M context, ~100 tps
Agent workflowsavelin-agentic-ultraTop-tier tool calling
Fast responsesavelin-fastLowest latency and cost

Why AVELIN for Mastra?

  • Production-ready: Automatic failover, retry logic, 99.9% uptime
  • Model diversity: 9 specialized models through one API key
  • Prompt caching: ~80% cost reduction on repeated prompts
  • Enterprise governance: Data sovereignty and compliance features

Troubleshooting

IssueSolution
API key errorVerify OPENAI_API_BASE includes /v1
Model not foundCheck model name matches exactly
Connection issuesVerify endpoint URL is correct
Rate limitingCheck your AVELIN plan limits