LLM API
Chat Completions
Spice provides an OpenAI compatible chat completion AI at https://data.spiceai.io/v1/chat/completions. Authorize with the endpoint using an App API key.
The App requires a configured and deployed model to respond to chat completion requests.
For more information about using chat completions, refer to the OpenAI documentation.
Creates a model response for the given chat conversation.
Chat completion generated successfully
The specified model was not found
An internal server error occurred while processing the chat completion
POST /v1/chat/completions HTTP/1.1
Host: data.spiceai.io
X-API-KEY: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 143
{
"model": "gpt-4o",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"stream": false
}
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o-mini",
"system_fingerprint": "fp_44709d6fcb",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21,
"completion_tokens_details": {
"reasoning_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}
Generate and optionally execute a natural-language text-to-SQL (NSQL) query.
This endpoint generates a SQL query using a natural language query (NSQL) and optionally executes it. The SQL query is generated by the specified model and executed if the Accept
header is not set to application/sql
.
The format of the response, one of 'application/json' (default), 'application/vnd.spiceai.nsql.v1+json', 'application/sql', 'text/csv' or 'text/plain'. 'application/sql' will only return the SQL query generated by the model.
SQL query executed successfully
Invalid request parameters
Internal server error
POST /v1/nsql HTTP/1.1
Host: data.spiceai.io
X-API-KEY: YOUR_API_KEY
Accept: text
Content-Type: application/json
Content-Length: 117
{
"query": "Get the top 5 customers by total sales",
"model": "nql",
"sample_data_enabled": true,
"datasets": [
"sales_data"
]
}
[
{
"customer_id": "12345",
"total_sales": 150000
},
{
"customer_id": "67890",
"total_sales": 125000
}
]
List all models, both machine learning and language models, available in the runtime.
The format of the response (e.g., json
or csv
).
If true, includes the status of each model in the response.
List of models in JSON format
Internal server error occurred while processing models
GET /v1/models HTTP/1.1
Host: data.spiceai.io
X-API-KEY: YOUR_API_KEY
Accept: */*
{
"object": "list",
"data": [
{
"id": "gpt-4",
"object": "model",
"owned_by": "openai",
"datasets": null,
"status": "ready"
},
{
"id": "text-embedding-ada-002",
"object": "model",
"owned_by": "openai-internal",
"datasets": [
"text-dataset-1",
"text-dataset-2"
],
"status": "ready"
}
]
}
Last updated
Was this helpful?