Skip to main content
The completions endpoint is the most direct way to generate text with Swytcho. You send a prompt, the model continues it, and you receive the generated text. This makes it ideal for structured generation tasks like writing product descriptions, summarizing documents, or producing formatted output in a single pass.

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 a POST 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.
Set temperature to 0 for fully deterministic, reproducible output — ideal for structured tasks like data extraction or classification. Raise it toward 1 or higher for creative writing, brainstorming, or variation-heavy tasks.

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 at choices[0].text.
Check choices[0].finish_reason to understand why generation stopped:
  • "stop" — the model reached a natural end or a stop sequence
  • "length" — the max_tokens limit was hit; consider increasing it if the output is cut off
  • "content_filter" — the output was blocked by safety filters
Extract the text and handle each finish reason in your application:
Python