Request/Response Schemas
This page details the JSON schemas for all Addis AI API endpoints, including request formats, response structures, and data types.
Overview
Addis AI API follows RESTful conventions with JSON-based request and response bodies. Understanding these schemas will help you properly format your requests and parse the responses.
Common Data Types
Message Object
Messages represent conversation turns in the chat API.
{
"role": string,
"content": string,
"name": string
}
Completion Choice Object
Represents a completion choice returned by the model.
{
"message": {
"role": string,
"content": string
},
"finish_reason": string,
"index": number
}
Usage Information Object
Contains token usage information for a request.
{
"prompt_tokens": number,
"completion_tokens": number,
"total_tokens": number
}
Chat Completion
Request
POST /v1/chat/completions
{
"model": string,
"messages": Array<Message>,
"temperature": number,
"top_p": number,
"n": number,
"stream": boolean,
"max_tokens": number,
"language": string,
"presence_penalty": number,
"frequency_penalty": number
}
Response
{
"id": string,
"object": "chat.completion",
"created": number,
"model": string,
"choices": Array<Choice>,
"usage": {
"prompt_tokens": number,
"completion_tokens": number,
"total_tokens": number
}
}
Streaming Response
When
stream
is set to
true
, the response is a stream of server-sent events, each containing a chunk of the response in the following format:
{
"id": string,
"object": "chat.completion.chunk",
"created": number,
"model": string,
"choices": [
{
"delta": {
"role": string,
"content": string
},
"index": number,
"finish_reason": null
}
]
}
The final chunk will have a
finish_reason
other than
null
.
Text-to-Speech
Request
POST /v1/audio/speech
{
"text": string,
"language": string,
"voice_id": string,
"output_format": string,
"speed": number,
"pitch": number
}
Response
The response is a binary audio file in the requested format with appropriate content type headers.
Speech-to-Text
Request
Multipart form data:
POST /v1/audio/transcribe
Content-Type: multipart/form-data
audio: file // Audio file to transcribe
language: string // Optional: "am" for Amharic, "om" for Afan Oromo
// If not specified, language will be auto-detected
prompt: string // Optional: Text to guide the transcription
timestamp_granularities: // Optional: "word" or "segment" for timestamps
Response
{
"id": string,
"text": string,
"language": string,
"duration": number,
"timestamps": Array<Timestamp>,
"segments": Array<Segment>
}
Where
Timestamp
and
Segment
are defined as:
{
"text": string,
"start": number,
"end": number
}
{
"id": number,
"text": string,
"start": number,
"end": number,
"confidence": number
}
Multi-Modal Input
Request
Multipart form data:
POST /v1/chat/multimodal
Content-Type: multipart/form-data
messages: JSON string // Same as chat completions messages
language: string // "am" for Amharic, "om" for Afan Oromo
images: file(s) // One or more image files
audio: file // Optional: Audio file
options: JSON string // Optional: Additional parameters
Where
options
can contain:
{
"temperature": number,
"top_p": number,
"max_tokens": number,
"stream": boolean
}
Response
The response format is the same as the chat completions API.
Error Responses
All API endpoints follow a consistent error response format:
{
"error": {
"message": string,
"type": string,
"param": string,
"code": string
}
}
For more details on error codes and handling, see the
Error Handling guide.
All API responses include headers with rate limit information:
x-ratelimit-limit: 60 // Requests allowed per time window
x-ratelimit-remaining: 59 // Requests remaining in current window
x-ratelimit-reset: 1677803439 // Unix timestamp when the limit resets
For more details on rate limits, see the
Rate Limits page.
Conclusion
This reference covers the primary schemas for Addis AI API endpoints. For additional details about specific endpoint behavior, refer to the
API Endpoints documentation.
If you encounter any issues or have questions about these schemas, please refer to our
FAQ and Troubleshooting guide.