Skip to content

Chat

  • create - Create chat completion

Create a chat completion, supports streaming

from r9s import R9S
import os
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s:
res = r9_s.chat.create(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": "Hello, how are you?",
},
],
stream=False)
print(res.choices[0].message)
ParameterTypeRequiredDescription
modelstr:heavy_check_mark:Model name
messagesArray:heavy_check_mark:Messages list
frequency_penaltyfloat:heavy_minus_sign:N/A
logit_biasobject:heavy_minus_sign:N/A
logprobsbool:heavy_minus_sign:N/A
top_logprobsint:heavy_minus_sign:N/A
max_tokensint:heavy_minus_sign:N/A
max_completion_tokensint:heavy_minus_sign:N/A
nint:heavy_minus_sign:N/A
presence_penaltyfloat:heavy_minus_sign:N/A
response_formatobject:heavy_minus_sign:N/A
seedfloat:heavy_minus_sign:N/A
service_tierstring (auto, default):heavy_minus_sign:N/A
stopstring or Array:heavy_minus_sign:N/A
streambool:heavy_minus_sign:N/A
stream_optionsobject:heavy_minus_sign:N/A
temperaturefloat:heavy_minus_sign:N/A
top_pfloat:heavy_minus_sign:N/A
top_kint:heavy_minus_sign:N/A
toolsArray:heavy_minus_sign:N/A
tool_choiceChatCompletionRequestobjectChoice:heavy_minus_sign:N/A
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateChatCompletionResponse

Error TypeStatus CodeContent Type
errors.BadRequestError400application/json
errors.AuthenticationError401application/json
errors.PermissionDeniedError403application/json
errors.UnprocessableEntityError422application/json
errors.RateLimitError429application/json
errors.InternalServerError500application/json
errors.ServiceUnavailableError503application/json
errors.R9SDefaultError4XX, 5XX*/*