Calling the API with curl

Calling the API with curl

After reading this guide, you can make a chat completion call from the command line with curl. Our API is OpenAI-compatible — for full parameter details, see the OpenAI API reference.

Request

curl https://api.tvtapi.com/v1/chat/completions \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-name",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Hello"}
    ]
  }'

Three substitutions:

  1. sk-xxxxxxxx → your API Key
  2. your-model-name → a model name copied from the model marketplace
  3. Hello → the message you want to send

Response

A JSON response is returned. The model's reply is in choices[0].message.content.

Common Parameters

  • temperature: randomness — 0 is most stable, 1 is most creative
  • max_tokens: caps the maximum reply length
  • stream: set to true for streaming output — the reply arrives token by token

Troubleshooting

  • 401: wrong Key — see Error Code Reference.
  • 429: too many requests — retry later.
  • No response for a long time: check your network and confirm the Base URL is https://api.tvtapi.com/v1.