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

Chat Completion Examples

curl https://data.spiceai.io/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "my_model","messages": [{"role": "system","content": "I am just like any other OpenAI server!"},{"role": "user","content": "Thats cool!"}]}' -H "Authorization: Bearer {APP_TOKEN}"

Example completion response:

{
  "id": "chatcmpl",
  "choices": [
    {
      "index": 0,
      "message": {
        "content": "Thank you! Is there anything specific you'd like to know or talk about?",
        "refusal": null,
        "tool_calls": null,
        "role": "assistant",
        "function_call": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "created": 1734572480,
  "model": "my_model",
  "service_tier": null,
  "system_fingerprint": null,
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 16,
    "total_tokens": 41,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}

Last updated