API Documentation
Complete reference for integrating with NextcraftAI's unified API. Build AI-powered applications with ease using a single interface for multiple LLM providers.
Base URL
https://api.nextcraftai.comAuthentication
All API endpoints require authentication using an API key. Include your API key in the Authorization header:
Authorization: Bearer sk-gateway-xxxxxxxxxxxxxGet your API key from the API Keys page in your dashboard after creating an account.
Endpoints Overview
| Method | Endpoint | Auth | Description |
|---|---|---|---|
GET | /health | None | Health check endpoint |
POST | /v1/chat/completions | API Key | Chat completions with AI models |
POST | /v1/multichat/completion | API Key | Send same message to multiple models simultaneously |
Using Different Models
NextcraftAI supports models from multiple providers. Specify the model in the request body using the model field. You can also specify the provider via query parameters or let the routing strategy choose automatically.
Google Gemini Models
| Model ID | Description |
|---|---|
| gemini-flash-2.5 | Fast and efficient model for quick responses |
| gemini-pro-2.5 | Pro model for advanced tasks (default) |
OpenAI Models
| Model ID | Description |
|---|---|
| gpt-5.2 | Latest GPT-5.2 model with advanced reasoning |
| gpt-4.1-mini | Next-generation mini model optimized for cost and latency |
For complete model listings and pricing information, visit our Models page.
Chat Completions (Raw API)
POST /v1/chat/completions
Send chat messages to AI models through a unified interface. Supports multiple providers (Google Gemini, OpenAI, xAI Grok) and intelligent routing strategies.
Request Body
{
"model": "gemini-pro-2.5",
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
],
"context": "You are a helpful AI assistant. Always be polite and concise.",
"temperature": 0.7,
"max_tokens": 1000
}Note: The context field is optional and allows you to provide system-level instructions or context that will be prepended as a system message to your conversation. This is useful for setting the AI's behavior, tone, or providing background information.
Code Examples
import requests
response = requests.post(
'https://api.nextcraftai.com/v1/chat/completions',
params={'provider': 'gemini'},
headers={
'Authorization': 'Bearer sk-gateway-xxxxxxxxxxxxx',
'Content-Type': 'application/json'
},
json={
'model': 'gemini-pro-2.5',
'messages': [
{'role': 'user', 'content': 'Hello, how are you?'}
],
'context': 'You are a helpful AI assistant. Always be polite and concise.',
'temperature': 0.7,
'max_tokens': 1000
}
)
data = response.json()
print(data['choices'][0]['message']['content'])Multichat Completions
POST /v1/multichat/completion
Send the same message to multiple AI models simultaneously for side-by-side comparison. Perfect for comparing responses from different models or providers. Supports up to 4 models per request.
Request Body
{
"models": [
{
"model": "gemini-pro-2.5",
"provider": "gemini"
},
{
"model": "gpt-5.2",
"provider": "openai"
}
],
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"context": "You are a science educator. Explain complex topics in simple, easy-to-understand language.",
"temperature": 0.7,
"max_tokens": 1000
}Note: The optional context field applies to all models in the multichat request, allowing you to set consistent system-level instructions across all model responses.
Error Handling
The API uses standard HTTP status codes and returns error objects in a consistent format:
{
"error": {
"message": "Insufficient wallet balance. Minimum required: $0.10",
"type": "invalid_request_error"
}
}Common Status Codes
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing authentication |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
Ready to Get Started?
Create an account, get your API key, and start building with NextcraftAI today.