Skip to content

Completions

  • create - Create text completion

Create a text completion, supports streaming

from r9s import R9S
with R9S(api_key=os.getenv("R9S_API_KEY",""),) as r9_s:
res = r9_s.completions.create(
model="gpt-4o-mini",
prompt="Once upon a time",
stream=False,
)
print(res.choices[0].text)
ParameterTypeRequiredDescription
modelstr:heavy_check_mark:Model name
promptstring or Array:heavy_check_mark:Prompt text
best_ofint:heavy_minus_sign:Generate multiple results and return the best one
echobool:heavy_minus_sign:Whether to echo the prompt
frequency_penaltyfloat:heavy_minus_sign:N/A
logit_biasobject:heavy_minus_sign:N/A
logprobsint:heavy_minus_sign:N/A
max_tokensint:heavy_minus_sign:N/A
nint:heavy_minus_sign:N/A
presence_penaltyfloat:heavy_minus_sign:N/A
seedint:heavy_minus_sign:N/A
stopstring or Array:heavy_minus_sign:N/A
streambool:heavy_minus_sign:N/A
suffixstr:heavy_minus_sign:N/A
temperaturefloat:heavy_minus_sign:N/A
top_pfloat:heavy_minus_sign:N/A
userstr:heavy_minus_sign:N/A
retriesobject:heavy_minus_sign:Configuration to override the default retry behavior of the client.

CreateCompletionResponse

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*/*