Completions vs. Chat Completions
Before reaching for the completions endpoint, consider which interface fits your use case.
Use the completions endpoint when you have a raw prompt you want continued or completed. Use chat completions when your task is better expressed as a conversation with a system instruction.
Send Your First Request
Make aPOST request to https://api.swytcho.com/v1/completions with your model, prompt, and any generation parameters.
Key Parameters
prompt
The text the model will continue. The quality and specificity of your prompt directly shapes the output. Include examples, formatting instructions, or constraints directly in the prompt string.
max_tokens
The maximum number of tokens to generate. One token is roughly four characters of English text. Set this to a value that comfortably fits your expected output — the model stops as soon as it hits this limit or produces a natural stopping point.
temperature
Controls the randomness of the output on a scale from 0 to 2.
stop
An array of up to four strings. The model halts generation as soon as it produces any of these sequences, and the stop string itself is not included in the output. Useful for trimming responses at a known boundary:
Working with the Response
A successful response returns a JSON object. The generated text lives atchoices[0].text.
choices[0].finish_reason to understand why generation stopped:
"stop"— the model reached a natural end or a stop sequence"length"— themax_tokenslimit was hit; consider increasing it if the output is cut off"content_filter"— the output was blocked by safety filters
Python