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}"
Create and run the example Python script to run a completion:
from openai import OpenAI
client = OpenAI(api_key="31393036|b0dd04f6892e4a38b3e829b0cea973b1", base_url="https://data.spiceai.io/v1")
response = client.chat.completions.create(
model="my_model",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
)
print(response.choices[0].message.content)
Running this example outputs a model response:
╰─± python test.py
The capital of France is Paris.