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

# API authentication

> Authenticate ScitiX Model Inference API requests with an API key and a Bearer header, verify your setup by listing models, and troubleshoot 401 errors.

The Model Inference API authenticates requests with an API key. Send the key in the `Authorization` header when listing models or creating a chat request. With the OpenAI Python SDK, set the `api_key` parameter instead.

## Get an API key

Open [**API Keys**](https://console.scitix.ai/model-inference/api_keys) in the console and click **Create API Key**, or use an existing enabled key.

For instructions on creating, pausing, resuming, and deleting keys or configuring spending quotas and rate limits, see [Manage API keys](https://docs.scitix.ai/model-inference/usage/api-keys.md).

## Configure authentication

The API base URL is `https://api.scitix.ai/model-api`. The compatible URL `https://api.scitix.ai/model-api/v1` is also available. Examples in this guide use the base URL without `/v1` and append the endpoint path.

### HTTP requests

Use the following header format. Replace `<YOUR_API_KEY>` with your key and keep the space after `Bearer`.

```http theme={null}
Authorization: Bearer <YOUR_API_KEY>
```

Set an environment variable in your local terminal to use the examples below. Replace `YOUR_API_KEY` with your actual key:

```bash theme={null}
export API_KEY="YOUR_API_KEY"
```

This command applies only to the current terminal session. Run it again when you open a new terminal, or add it to your shell's user startup configuration to load it automatically.

> [!WARNING]
>
> Do not expose real keys in repositories, public documentation, screenshots, logs, browser frontends, or other client-side code. An environment variable does not replace secret protection. Remove keys before sharing terminal output or logs.

### Python SDK

Set `api_key` when using the OpenAI Python SDK. Do not add the `Bearer` prefix to this value:

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

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.scitix.ai/model-api",
)
```

Use the API base URL for `base_url`, without `/chat/completions`. The SDK appends the endpoint path. If you receive `KeyError: 'API_KEY'`, set the environment variable in the terminal that runs the script. For SDK installation and a complete request example, see [Make your first API call](https://docs.scitix.ai/model-inference/get-started/first-api-call.md).

## Verify authentication

List models to check your key and header configuration. This request does not require a model ID or request body:

```bash theme={null}
curl --include --silent --show-error --max-time 30 \
  'https://api.scitix.ai/model-api/models' \
  --header "Authorization: Bearer ${API_KEY}"
```

The `--include` option displays the HTTP status and response headers. Check the status first, then the body:

* HTTP `200` with `object: "list"` and a model array in `data` means this model-list request succeeded.
* HTTP `401` means you need to check the key and authentication header.
* For other status codes, follow the actual error response. Do not treat every error as an authentication failure.

A successful model-list request does not mean every model supports chat requests, or that later calls will be exempt from spending quotas or rate limits. Check the model's supported protocol and preserve the exact capitalization and vendor prefix in its ID.

## Troubleshoot authentication failures

HTTP `401` indicates an authentication failure. The common error type is `authentication_error`, with code `unauthorized`. Use the actual error message to identify what to check:

| Error message | What to check |
| - | - |
| `Missing authorization header` | Confirm that the request includes an `Authorization` header. |
| `authorization api key not valid` | Check the key value, header format, and key status. |

Messages help with diagnosis but should not be your application's only error signal. Also check the HTTP status, `error.type`, and `error.code`.

1. Confirm that the request sends `Authorization: Bearer <YOUR_API_KEY>`.
2. Check that the environment variable is set in the terminal or application process making the request. Ensure it is not still a placeholder and contains no extra spaces or newlines. Do not print the full key to debug it.
3. Check in the console that the key is enabled and has not been deleted. Resume a paused key; replace a deleted key.
4. Correct the configuration, then send the model-list request again. Do not repeatedly retry with unchanged invalid credentials.

HTTP `402` indicates a billing requirement is not met. For `429`, use the error type to distinguish a rate limit from a capacity issue. Neither should be handled as an invalid key.

* For spending quotas and rate settings, see [Manage API keys](https://docs.scitix.ai/model-inference/usage/api-keys.md).
* For throttling guidance, see [Rate limits](https://docs.scitix.ai/model-inference/api/rate-limits.md).

If authentication still fails, contact technical support with the `request_id`, request time and time zone, endpoint path, HTTP status, and error body. See [Error handling](https://docs.scitix.ai/model-inference/api/error-handling.md). Remove API keys and other sensitive information first.


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