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

# cURL / Python / Node.js

> Chiama l'API direttamente con le librerie ufficiali di OpenAI

Qualsiasi libreria ufficiale di OpenAI funziona; cambia solo `base_url`. Gli esempi usano `gpt-5.6-sol`; per il pacchetto Astra usa `gpt-astra`.

## Chat Completions

<CodeGroup>
  ```bash cURL theme={null}
  curl https://gpt.teamsoclo.site/v1/chat/completions \
    -H "Authorization: Bearer sk-xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.6-sol",
      "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain closures in JavaScript"}
      ]
    }'
  ```

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

  client = OpenAI(
      api_key="sk-xxx",
      base_url="https://gpt.teamsoclo.site/v1",
  )

  resp = client.chat.completions.create(
      model="gpt-5.6-sol",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Explain closures in JavaScript"},
      ],
  )

  print(resp.choices[0].message.content)
  print(resp.usage)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai"

  const client = new OpenAI({
    apiKey: "sk-xxx",
    baseURL: "https://gpt.teamsoclo.site/v1",
  })

  const resp = await client.chat.completions.create({
    model: "gpt-5.6-sol",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Explain closures in JavaScript" },
    ],
  })

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

<Warning>
  `base_url` deve includere `/v1` e **non** deve terminare con `/`. La libreria aggiunge `/chat/completions` da sola.
</Warning>

Le risposte seguono esattamente lo schema di OpenAI: `id` è `chatcmpl-...`, `usage` ha `prompt_tokens`, `completion_tokens` e `completion_tokens_details.reasoning_tokens`. Il credito viene addebitato esattamente `usage.total_tokens`.

## Responses API

Codex e i nuovi SDK usano questo protocollo. L'impostazione di ragionamento si trova in `reasoning.effort`.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://gpt.teamsoclo.site/v1/responses \
    -H "Authorization: Bearer sk-xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.6-sol",
      "input": "Write a Python function that checks for primes",
      "reasoning": {"effort": "medium"}
    }'
  ```

  ```python Python theme={null}
  resp = client.responses.create(
      model="gpt-5.6-sol",
      input="Write a Python function that checks for primes",
      reasoning={"effort": "medium"},
  )
  print(resp.output_text)
  ```
</CodeGroup>

## Livello di ragionamento

Con Chat Completions usa `reasoning_effort` (`low`, `medium`, `high`). Se non impostato, il gateway usa `high`. Per compiti semplici imposta `low` per risparmiare token:

```python theme={null}
resp = client.chat.completions.create(
    model="gpt-5.6-sol",
    reasoning_effort="low",
    messages=[{"role": "user", "content": "Translate to French: good morning"}],
)
```

<Warning>
  `reasoning_effort` è solo per Chat Completions. Con la Responses API usa `reasoning: {"effort": ...}`; inviare `reasoning_effort` a `/v1/responses` viene rifiutato con "Unsupported parameter".
</Warning>

## Streaming

<CodeGroup>
  ```python Python theme={null}
  stream = client.chat.completions.create(
      model="gpt-5.6-sol",
      messages=[{"role": "user", "content": "Write a short paragraph about autumn"}],
      stream=True,
      stream_options={"include_usage": True},
  )

  for chunk in stream:
      if chunk.choices and chunk.choices[0].delta.content:
          print(chunk.choices[0].delta.content, end="", flush=True)
      if chunk.usage:
          print("\n", chunk.usage)
  ```

  ```bash cURL theme={null}
  curl https://gpt.teamsoclo.site/v1/chat/completions \
    -H "Authorization: Bearer sk-xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.6-sol",
      "messages": [{"role": "user", "content": "Write a short paragraph about autumn"}],
      "stream": true,
      "stream_options": {"include_usage": true}
    }'
  ```
</CodeGroup>

<Tip>
  Su domande difficili il modello potrebbe pensare a lungo prima del primo token. Usa `stream: true` in modo che la connessione non venga interrotta. `stream_options.include_usage` fa sì che l'ultimo chunk porti `usage` in modo che tu possa riconciliare il credito da solo.
</Tip>

## Invio di immagini (visione)

Le immagini vanno nell'array `content`, come URL pubblica o base64 per i file locali.

<CodeGroup>
  ```python Image URL theme={null}
  resp = client.chat.completions.create(
      model="gpt-5.6-sol",
      messages=[{
          "role": "user",
          "content": [
              {"type": "text", "text": "What error does this show?"},
              {"type": "image_url", "image_url": {"url": "https://example.com/screenshot.png"}},
          ],
      }],
  )
  print(resp.choices[0].message.content)
  ```

  ```python Local file (base64) theme={null}
  import base64

  with open("screenshot.png", "rb") as f:
      b64 = base64.b64encode(f.read()).decode()

  resp = client.chat.completions.create(
      model="gpt-5.6-sol",
      messages=[{
          "role": "user",
          "content": [
              {"type": "text", "text": "What error does this show?"},
              {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
          ],
      }],
  )
  print(resp.choices[0].message.content)
  ```
</CodeGroup>

<Warning>
  Le immagini costano token in base alla loro dimensione. Ritaglia la parte rilevante invece di inviare uno screenshot 4K completo.
</Warning>

## Modelli e credito tramite API

```bash theme={null}
# Modelli che questa chiave può chiamare
curl https://gpt.teamsoclo.site/v1/models -H "Authorization: Bearer sk-xxx"

# Credito (endpoint OpenAI legacy)
curl https://gpt.teamsoclo.site/v1/dashboard/billing/subscription -H "Authorization: Bearer sk-xxx"
curl https://gpt.teamsoclo.site/v1/dashboard/billing/usage -H "Authorization: Bearer sk-xxx"
```

`subscription` restituisce il totale in `hard_limit_usd`; `usage` restituisce ciò che è stato usato in `total_usage`, in **centesimi** (dividi per 100 prima di confrontare). La [pagina di verifica](https://gpt.teamsoclo.site/check) fa questo per te.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.