Vai al contenuto
Documentazione:OpenAI-compatible API

API

OpenAI-compatible API

Use the official OpenAI SDKs for chat completions and audio transcription by changing the base URL and the API key.

Questa pagina non è ancora stata tradotta. Viene mostrata la versione inglese.

Chat and speech-to-text models are served through endpoints that follow the OpenAI API. If your code already uses an OpenAI SDK, two settings change: the base URL and the API key.

EndpointUse
POST /v1/chat/completionsChat, with or without streaming
POST /v1/audio/transcriptionsSpeech-to-text
GET /v1/modelsThe models available to your organization

Other OpenAI endpoints are not served. Images, video and music are generated with the Task API.

Point the SDK at Minu

Set the base URL to https://api.minu.ai/v1 and pass your Minu key.

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.MINU_API_KEY,
  baseURL: 'https://api.minu.ai/v1',
});

The official SDKs also read the environment variables OPENAI_API_KEY and OPENAI_BASE_URL, so a program you cannot change can often be pointed at Minu without touching its code:

Shell
export OPENAI_API_KEY="$MINU_API_KEY"
export OPENAI_BASE_URL="https://api.minu.ai/v1"

Chat completions

Use a model ID from the model reference, such as deepseek/deepseek-v4.1-flash. Model IDs have the form vendor/model.

const completion = await client.chat.completions.create({
  model: 'deepseek/deepseek-v4.1-flash',
  messages: [
    { role: 'system', content: 'You answer in one short paragraph.' },
    { role: 'user', content: 'What is an idempotency key?' },
  ],
});

console.log(completion.choices[0].message.content);
console.log(completion.usage);

Streaming

Set stream to true to receive the answer as it is written, as server-sent events in the OpenAI format.

const stream = await client.chat.completions.create({
  model: 'deepseek/deepseek-v4.1-flash',
  messages: [{ role: 'user', content: 'Explain webhooks in three sentences.' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

Audio transcriptions

Send the audio as a multipart form with the model openai/whisper.

import fs from 'node:fs';

const transcript = await client.audio.transcriptions.create({
  file: fs.createReadStream('meeting.mp3'),
  model: 'openai/whisper',
});

console.log(transcript.text);

The optional form fields are listed with the model in the model reference.

List models

GET /v1/models returns the models in the shape of the OpenAI models list, with two fields added: modality and kind.

Shell
curl https://api.minu.ai/v1/models \
  -H "Authorization: Bearer $MINU_API_KEY"
JSON
{
  "object": "list",
  "data": [
    {
      "id": "deepseek/deepseek-v4.1-flash",
      "object": "model",
      "created": 1796169600,
      "owned_by": "deepseek",
      "modality": "chat",
      "kind": "chat"
    },
    {
      "id": "google/nano-banana-2",
      "object": "model",
      "created": 1796169600,
      "owned_by": "google",
      "modality": "image",
      "kind": "task"
    }
  ]
}

The list holds every model, not only the chat models. kind tells you which API a model belongs to:

kindCall it with
chatPOST /v1/chat/completions
transcriptionPOST /v1/audio/transcriptions
taskPOST /v1/tasks

Billing

Chat and transcription calls are paid from the same prepaid balance as tasks, when the call completes.

  • Chat is priced per million tokens, with separate prices for input, cached input and output. The usage object of the response reports the token counts.
  • Transcription is priced by the length of the audio.

Prices are published in the catalog: see the pricing page and the model reference. Each call appears in the console under Logs, with its token counts or audio length and its cost.

Errors and limits

  • Errors use the same status codes and the same error.code values as the rest of the API, so the SDKs raise their usual exception types. See Errors and rate limits.
  • The rate limit of your organization covers these endpoints too.
  • A key restricted to certain models answers 403 model_not_allowed for any other model.