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.