Spicy AI API Documentation

Use the Spicy AI API to add chat and image generation to your app. One API key connects both workflows using your Spicy AI credits.

Chat

1 credit / 1,000 tokens

Call chat from your app with a Spicy AI API key. Billing rounds up to the next 1,000 tokens, with a minimum of 1 credit per request.

Example request

curl https://spicyai.app/api/v1/chat/completions \
  -H "Authorization: Bearer sk-spicy-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Hello"}]}'

Send a messages array with user, assistant or system messages. Set stream: true for an SSE response. Optional fields: temperature and max_tokens.

Non-streaming responses include choices, token usage, request cost and remaining credits. Use the same key for text-to-image generation.

Build with the Spicy AI API

The Spicy AI API connects conversational and image workflows in your application. Use the Chat API for an interactive assistant or character conversation, and the image generation API to turn a written scene into a picture. Both use the same API key, while their response formats and billing rules differ. Choose the tab above for request examples and parameters.

Spicy AI API Authentication

Create a key in API Keys and send it in the Authorization header as a Bearer token. Keep the key on your server rather than embedding it in public browser code. The examples use a placeholder: replace it with your own key when making a request. Your application should handle authentication errors before retrying a generation.

Chat API: Messages and Streaming

Send the conversation as a messages array to the Spicy AI API chat endpoint. Include the relevant conversation history so each request has the context it needs. Use streaming when your interface should display text as it arrives, or a non-streaming request when you need a complete response. Check token usage and credit cost in the response when tracking application spending.

Image Generation API: Submit and Poll

The Spicy AI API image workflow is asynchronous. Submit a text prompt, save the returned task ID, then poll the status URL to retrieve the image when it is ready. This separates the initial request from generation time and lets your interface show a pending state. Retry status checks on temporary errors; submitting the prompt again creates a separate paid request.

Plan Your Spicy AI API Integration

Start with one request and verify its response before connecting a full user flow. For chat, handle both complete and streamed responses. For images, handle pending, succeeded and failed tasks. Review the billing information in each tab: chat uses token-based charges, while image generation has a per-image cost. These differences matter when showing progress and costs to your users.

Sign in

Welcome to Spicy AI