> ## Documentation Index
> Fetch the complete documentation index at: https://developer.swytcho.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Swytcho API Requests: Headers, Body, and Parameters

> Learn the base URL, required headers, request body schema, and key parameters needed to send well-formed requests to the Swytcho API.

All Swytcho API requests follow a consistent structure, regardless of which model or endpoint you call. Once you understand the pattern, you can apply it to every feature the API offers — from chat completions to embeddings — without having to re-learn the basics each time.

## Base URL

Every request targets the following base URL:

```text theme={null}
https://api.swytcho.com/v1
```

Append the relevant path for your operation — for example, `https://api.swytcho.com/v1/chat/completions` for chat completions.

## Required Headers

Every request must include the headers below.

| Header          | Value                 |
| --------------- | --------------------- |
| `Authorization` | `Bearer YOUR_API_KEY` |
| `Content-Type`  | `application/json`    |

Obtain your API key from the [Swytcho Dashboard](https://dashboard.swytcho.com). Store it in an environment variable — never hard-code it in source files.

## Request Body

Send a JSON body with your request. At a minimum, provide the `model` field and the input content (`messages` for chat, `input` for embeddings). All other fields are optional.

### Key Parameters

<ParamField body="model" type="string" required>
  The ID of the model to use, for example `"swytcho-1"` or `"swytcho-1-mini"`. See [Models](/concepts/models) for the full list of available model IDs.
</ParamField>

<ParamField body="max_tokens" type="integer">
  The maximum number of tokens to generate in the response. The request's input tokens plus `max_tokens` must not exceed the model's context window. Defaults to the model's maximum output if omitted.
</ParamField>

<ParamField body="temperature" type="number">
  Controls randomness in the output. Values range from `0` (deterministic) to `2` (highly random). Use lower values for factual or structured tasks; higher values for creative tasks. Defaults to `1`.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling threshold. The model considers only the tokens whose cumulative probability mass reaches `top_p`. Range: `0` to `1`. Defaults to `1`. Swytcho recommends adjusting either `temperature` or `top_p`, but not both at the same time.
</ParamField>

<ParamField body="stream" type="boolean">
  When `true`, the API streams partial response tokens back as server-sent events (SSE) instead of waiting for the full completion. Defaults to `false`. See the [Streaming guide](/guides/streaming) for details on consuming the event stream.
</ParamField>

## Example Request

The example below sends a chat completion request using `curl`. Swap in your own API key and adjust the messages array for your use case.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.swytcho.com/v1/chat/completions \
    -H "Authorization: Bearer $SWYTCHO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "swytcho-1-mini",
      "messages": [
        {
          "role": "system",
          "content": "You are a helpful assistant."
        },
        {
          "role": "user",
          "content": "Summarize the key benefits of retrieval-augmented generation."
        }
      ],
      "max_tokens": 512,
      "temperature": 0.7
    }'
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["SWYTCHO_API_KEY"],
      base_url="https://api.swytcho.com/v1",
  )

  response = client.chat.completions.create(
      model="swytcho-1-mini",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Summarize the key benefits of retrieval-augmented generation."},
      ],
      max_tokens=512,
      temperature=0.7,
  )

  print(response.choices[0].message.content)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.SWYTCHO_API_KEY,
    baseURL: "https://api.swytcho.com/v1",
  });

  const response = await client.chat.completions.create({
    model: "swytcho-1-mini",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Summarize the key benefits of retrieval-augmented generation." },
    ],
    max_tokens: 512,
    temperature: 0.7,
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

<Tip>
  Swytcho enforces a **default request timeout of 120 seconds**. For long-form generation tasks, enable streaming (`"stream": true`) so you can start processing tokens immediately and avoid timeout errors on large outputs. If you are using a client library, set its timeout to at least 120 seconds to match the server-side limit.
</Tip>
