Tuna.ai

Authentication

The Tuna API requires an API key, except when listing models.

API Keys

API keys belong to a project, and projects belong to an organization. A request made with a key is charged to that key's organization. See Organizations and projects.

Create keys in a project on the Tuna dashboard. API keys start with tuna_. Treat each key like a password:

  • Keep keys on your server. Code in a web page or a mobile app runs on your users' devices, so anyone can read a key that is in it.
  • Follow general security best practices for storing and handling API keys.
  • Use a separate key for each app and each environment, like production and staging, so you can replace one without touching the others.

Sending the Key

Send the key in the Authorization header as a Bearer token.

POST /v1/chat/completions HTTP/1.1
Host: api-us.tuna.ai
Authorization: Bearer tuna_yourApiKeyHereWithTunaUnderscore
Content-Type: application/json

The OpenAI SDKs do this for you when you pass api_key in Python or apiKey in JavaScript.

Errors

Status Message What to do
401 You must provide an API key. Add the Authorization header.
401 The API key you provided is invalid. Check the key for typos, or create a new one.

See Errors for the other errors the API can return.