Client Libraries

Mixlayer exposes OpenAI-compatible Chat Completions and Responses APIs at https://models.mixlayer.ai/v1. Any client library that supports either API can use Mixlayer — point it at the Mixlayer base URL and pass your Mixlayer API key.

You can create an API key from the Mixlayer console.

Installation

No installation required — curl is preinstalled on most systems.

Basic chat completion

file=chat.sh
$curl https://models.mixlayer.ai/v1/chat/completions \
> -H "Authorization: Bearer $MIXLAYER_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "qwen/qwen3.5-4b-free",
> "messages": [
> {"role": "system", "content": "You are a helpful assistant."},
> {"role": "user", "content": "Tell me a fun fact about chihuahuas."}
> ]
> }'

Streaming

Pass stream: true to receive tokens as Server-Sent Events as they’re generated.

file=stream.sh
$curl https://models.mixlayer.ai/v1/chat/completions \
> -H "Authorization: Bearer $MIXLAYER_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "qwen/qwen3.5-4b-free",
> "stream": true,
> "messages": [
> {"role": "user", "content": "Tell me a fun fact about chihuahuas."}
> ]
> }'

See Chat Completions for the full list of supported request parameters and the streaming event shape.

Vercel AI SDK

You can also use Mixlayer via the OpenAI-compatible provider in the Vercel AI SDK.

$npm install ai @ai-sdk/openai
file=route.ts
1import { createOpenAI } from "@ai-sdk/openai";
2import { streamText } from "ai";
3import type { NextRequest } from "next/server";
4
5const mixlayer = createOpenAI({
6 apiKey: process.env.MIXLAYER_API_KEY,
7 baseURL: "https://models.mixlayer.ai/v1",
8});
9
10export async function POST(req: NextRequest) {
11 const { prompt } = await req.json();
12
13 const result = streamText({
14 model: mixlayer.chat("qwen/qwen3.5-397b-a17b"),
15 prompt,
16 maxTokens: 1000,
17 });
18
19 return result.toDataStreamResponse();
20}