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

# Authentication

> Get your API key and authenticate requests to the Artificial Studio API.

All API requests require an API key passed in the `Authorization` header.

## Get your API key

<Steps>
  <Step title="Sign in">
    Go to [Artificial Studio](https://app.artificialstudio.ai) and sign in to your account.
  </Step>

  <Step title="Create a key">
    Navigate to [API Keys](https://app.artificialstudio.ai/account/api-keys) and click **Create API Key**.
  </Step>

  <Step title="Store it securely">
    Copy and save your key. It is only shown once.
  </Step>
</Steps>

<Warning>Your API key is only displayed once. Store it in an environment variable or secrets manager — not in your source code.</Warning>

## Using your API key

Include the key in the `Authorization` header of every request:

<CodeGroup>
  ```bash bash theme={null}
  curl -X POST https://api.artificialstudio.ai/api/run \
    -H "Authorization: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"tool": "create-image", "input": {"prompt": "Hello world"}}'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.artificialstudio.ai/api/run', {
    method: 'POST',
    headers: {
      'Authorization': process.env.ARTIFICIAL_STUDIO_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      tool: 'create-image',
      input: { prompt: 'Hello world' }
    })
  });
  ```

  ```python Python theme={null}
  import requests
  import os

  response = requests.post(
      'https://api.artificialstudio.ai/api/run',
      headers={
          'Authorization': os.environ['ARTIFICIAL_STUDIO_API_KEY'],
          'Content-Type': 'application/json'
      },
      json={
          'tool': 'create-image',
          'input': {'prompt': 'Hello world'}
      }
  )
  ```
</CodeGroup>

<Note>Pass your API key directly in the `Authorization` header. Do **not** use the `Bearer` prefix.</Note>

## Security best practices

* **Never expose your API key** in client-side code or public repositories
* **Use environment variables** to store your key
* **Rotate keys regularly** if you suspect they have been compromised
* **Use separate keys** for development and production

## Rate limits

| Endpoint        | Free       | Pro         |
| --------------- | ---------- | ----------- |
| `POST /api/run` | 20 req/min | 60 req/min  |
| `GET` endpoints | 60 req/min | 200 req/min |

When you exceed the rate limit, the API returns `429 Too Many Requests`. Wait before retrying.

## Credits

Each generation consumes credits. The cost depends on the tool and model — check each model's documentation page for pricing.

* View your balance at [Account Settings](https://app.artificialstudio.ai/account/settings)
* Running out of credits returns `402 Payment Required`
