Skip to main content

Chat Server API

DeepAuto.ai chat server is designed to support the new Chat Completions API by OpenAI, enabling dynamic interactions with the model. It offers an interactive an interactive interface to communicate with the model, allowing back-and-forth exchanges that can be stored in the chat history.

You can easily communicate with the model using curl:

curl https://lang.deepauto.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEEPAUTO_API_KEY" \
-d '{
"model": "DeepAuto.ai/deepauto-ai-optimized-Qwen1.5-14B-Chat",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Who won the world series in 2020?"
},
{
"role": "assistant",
"content": "The Los Angeles Dodgers won the World Series in 2020."
},
{
"role": "user",
"content": "Where was it played?"
}
]
}'

You also can use the API by using the openai package in Python:

from openai import OpenAI

deepauto_base = "https://lang.deepauto.ai/v1"
# Get one from DeepAuto.ai
deepauto_api_key = "DEEPAUTO_API_KEY"
model = "DeepAuto.ai/deepauto-ai-optimized-Qwen1.5-14B-Chat"

client = OpenAI(
base_url=deepauto_base,
api_key=deepauto_api_key,
)

response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"},
],
)

print("Chat response:", response)

To mimic the effect seen in ChatGPT where the text is returned in real time, set the stream parameter to true.

from openai import OpenAI

deepauto_base = "https://lang.deepauto.ai/v1"
# Get one from DeepAuto.ai
deepauto_api_key = "DEEPAUTO_API_KEY"
model = "DeepAuto.ai/deepauto-ai-optimized-Qwen1.5-14B-Chat"

client = OpenAI(
base_url=deepauto_base,
api_key=deepauto_api_key,
)

stream = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"},
],
stream=True,
)

print("Chat stream response: ", end="")
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")
print("")
info

To learn more, you can view the full API reference documentation for the OpenAI Chat Completion API.