API Documentation

Everything you need to integrate SparkAI Stream into your applications

🚧

Coming Soon

Our API is currently under development. The documentation below shows what will be available at launch.

Authentication

All API requests require authentication using an API key. Include your key in the request header:

Authorization: Bearer YOUR_API_KEY

Generate API keys from your dashboard once you create an account.

Chat API

Send messages to our AI and receive streaming or complete responses.

Endpoint

POST https://api.sparkaistream.com/v1/chat

Request Body

{
  "model": "spark-1",
  "messages": [
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "max_tokens": 1000,
  "temperature": 0.7,
  "stream": true
}

Response

{
  "id": "chat-abc123",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "spark-1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm doing great. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 18,
    "total_tokens": 30
  }
}

Example (cURL)

curl https://api.sparkaistream.com/v1/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "spark-1",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

Example (Python)

import requests

response = requests.post(
    "https://api.sparkaistream.com/v1/chat",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "model": "spark-1",
        "messages": [{"role": "user", "content": "Hello!"}],
        "stream": True
    }
)

print(response.json())

Example (JavaScript)

const response = await fetch('https://api.sparkaistream.com/v1/chat', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'spark-1',
    messages: [{ role: 'user', content: 'Hello!' }],
    stream: true
  })
});

const data = await response.json();
console.log(data);

Available Models

Model Description Max Tokens Price
spark-1 Balanced model for most tasks 4,096 $0.0003/1K tokens
spark-turbo Optimized for speed 4,096 $0.0006/1K tokens
spark-pro Enhanced reasoning & analysis 8,192 $0.0012/1K tokens

Rate Limits

Plan Requests/min Tokens/min
Starter 30 15,000
Pro 90 75,000
Enterprise Custom Custom

Error Handling

The API uses standard HTTP response codes:

Code Description
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
429Too Many Requests - Rate limit exceeded
500Server Error

Official SDKs

We'll provide official SDKs for popular languages:

Python

pip install sparkaistream Coming Soon

JavaScript/Node.js

npm install sparkaistream Coming Soon

PHP

composer require sparkaistream/sdk Coming Soon

Ready to Build?

Join our waitlist to get early API access.

Join Waitlist