Skip to content

AI Model APIs — Overview

ModuCompia AI provides a unified, OpenAI-compatible API for accessing AI models from multiple providers. All endpoints follow the OpenAI API specification, so existing SDKs and integrations work without modification.

Base URL

https://ai.moducompia.com/v1

Supported Endpoints

OpenAI-compatible:

Endpoint Method Description
/v1/models, /v1/models/{model} GET List / retrieve models
/v1/chat/completions POST Chat conversation completion
/v1/completions POST Text completion (legacy)
/v1/responses POST Responses API
/v1/embeddings POST Generate text embeddings
/v1/images/generations, /v1/images/edits POST Generate / edit images
/v1/audio/speech POST Text-to-speech
/v1/audio/transcriptions, /v1/audio/translations POST Speech-to-text, translated speech-to-text
/v1/rerank POST Document reranking
/v1/moderations POST Content moderation
/v1/realtime WebSocket Realtime audio/text sessions

Provider-native protocols, for SDKs that don't speak the OpenAI dialect — same key, same account, same billing:

Endpoint Method Description
/v1/messages POST Anthropic Messages API
/v1beta/models/{model}:{action} POST Gemini generateContent / streamGenerateContent
/v1beta/models, /v1beta/openai/models GET Gemini-style model listing

Asynchronous jobs use a submit-then-poll pattern under their own prefixes: /mj/… (Midjourney) and /suno/… (music). Submit a task, then poll its fetch endpoint for the result.

Not implemented

Files and fine-tuning routes (/v1/files…, /v1/fine-tunes…) and /v1/images/variations exist for SDK compatibility but return a not-implemented error.

Common Request Headers

Authorization: Bearer sk-YOUR_API_KEY
Content-Type: application/json

Anthropic and Gemini SDKs may send the key as x-api-key, x-goog-api-key or ?key= instead — all are accepted on their respective endpoints. See Authentication.

Common Response Format

All endpoints return JSON with a consistent structure. Successful responses include:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1723456789,
  "model": "gpt-4o",
  "choices": [...],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 25,
    "total_tokens": 35
  }
}

Error Format

{
  "error": {
    "message": "Insufficient balance",
    "type": "insufficient_quota",
    "code": 402
  }
}

Streaming

Most generation endpoints support streaming via "stream": true. When enabled, the response is delivered as Server-Sent Events (SSE):

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":" there"}}]}

data: [DONE]