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.com

Authentication

All API endpoints require authentication using an API key. Include your API key in the Authorization header:

http
Authorization: Bearer sk-gateway-xxxxxxxxxxxxx

Get your API key from the API Keys page in your dashboard after creating an account.

Endpoints Overview

MethodEndpointAuthDescription
GET/healthNoneHealth check endpoint
POST/v1/chat/completionsAPI KeyChat completions with AI models
POST/v1/multichat/completionAPI KeySend 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 IDDescription
gemini-flash-2.5Fast and efficient model for quick responses
gemini-pro-2.5Pro model for advanced tasks (default)

OpenAI Models

Model IDDescription
gpt-5.2Latest GPT-5.2 model with advanced reasoning
gpt-4.1-miniNext-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

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
}

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

python
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

json
{
  "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:

json
{
  "error": {
    "message": "Insufficient wallet balance. Minimum required: $0.10",
    "type": "invalid_request_error"
  }
}

Common Status Codes

400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing authentication
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Ready to Get Started?

Create an account, get your API key, and start building with NextcraftAI today.