Authentication

All API requests require an API key. Include your API key in the Authorization header of every request.

curl https://api.mollyra.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
# Python
import requests

headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}

Chat Completions

Create chat-based completions using our advanced language models. Supports streaming, system messages, and multi-turn conversations.

POST /v1/chat/completions

Request Body

ParameterTypeDescription
modelrequiredstringThe model to use (gpt-4-turbo, claude-3-opus, mollyra-x)
messagesrequiredarrayArray of message objects with role and content
temperatureoptionalnumberSampling temperature (0-2). Default: 0.7
max_tokensoptionalintegerMaximum tokens to generate. Default: 2048
streamoptionalbooleanEnable streaming responses. Default: false
{
"model": "gpt-4-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7,
"max_tokens": 1000
}

Response

{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4-turbo",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 20, "completion_tokens": 10, "total_tokens": 30}
}

Image Generation

Generate images from text prompts using DALL-E 3 and our custom diffusion models.

POST /v1/images/generations

Request Body

ParameterTypeDescription
promptrequiredstringText description of the desired image
modeloptionalstringImage model to use (dall-e-3, mollyra-diffusion). Default: dall-e-3
noptionalintegerNumber of images to generate (1-10). Default: 1
sizeoptionalstringImage size (1024x1024, 1792x1024, 1024x1792)
{
"prompt": "A futuristic cyberpunk city with neon lights, purple and cyan color scheme",
"model": "dall-e-3",
"n": 1,
"size": "1024x1024"
}

Embeddings

Generate vector embeddings for text, useful for semantic search, clustering, and similarity matching.

POST /v1/embeddings
ParameterTypeDescription
inputrequiredstring or arrayText to embed
modeloptionalstringEmbedding model (text-embedding-3-small, text-embedding-3-large)

Available Models

ModelTypeContext WindowBest For
gpt-4-turboChat128K tokensComplex reasoning, coding
gpt-3.5-turboChat16K tokensFast responses, cost efficiency
claude-3-opusChat200K tokensLong documents, analysis
claude-3-sonnetChat200K tokensBalanced performance
mollyra-xChat32K tokensSpecialized tasks
dall-e-3Image-High-quality images

Rate Limits

Rate limits vary by plan. Upgrade to Enterprise for higher limits.

PlanRequests/minuteTokens/minute
Free2010,000
Pro500500,000
EnterpriseCustomCustom

Error Handling

Our API uses standard HTTP status codes. Error responses include a JSON body with details.

CodeMeaning
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Insufficient permissions
429Too Many Requests - Rate limit exceeded
500Server Error - Something went wrong on our end

Official SDKs

Official SDKs are available for popular programming languages.

Python

pip install mollyra

Node.js

npm install mollyra-sdk

Go

go get github.com/mollyra/sdk

Ruby

gem install mollyra