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

# API Keys & Billing

> Create and manage API keys, top up your API balance, and understand per-model pricing so you can ship Krea integrations with predictable costs.

## Creating API Keys

Only workspace **owners** and **admins** can create API tokens. If you don't see the option to create a token, contact your workspace owner to request access or an elevated role.

To create an API key:

1. Navigate to [krea.ai/settings/api-tokens](https://www.krea.ai/settings/api-tokens)
2. Make sure you're in the correct workspace (using the workspace toggle on the top left)
3. Click "New Token"
4. Give your token a descriptive name
5. Save the token securely—you'll only see it once!

<Info>
  The API operates as its own user identity within your workspace. Styles trained in the app won't be accessible via the API, and styles trained via the API won't appear in the app, unless they are shared with the workspace. See [Train a Custom Style](/developers/tutorials/train-image-style#use-your-trained-style) for details.
</Info>

<Warning>
  **Security Guidelines**

  * Store tokens in environment variables, never in code
  * Use different tokens for development and production
  * Revoke tokens immediately if compromised
  * Never commit tokens to version control
  * Never share tokens publicly
</Warning>

## Using API Keys

Include your token in the `Authorization` header of all requests:

<CodeGroup>
  ```javascript Node.js theme={null}
  // npm install @krea-ai/sdk
  import { Krea } from "@krea-ai/sdk";

  const krea = new Krea({ apiKey: process.env.KREA_API_KEY });

  const job = await krea.image("bfl/flux-1-dev", {
    prompt: "a serene mountain landscape at sunset",
    width: 1024,
    height: 576
  });

  console.log(`Job ID: ${job.job_id}`);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.krea.ai/generate/image/bfl/flux-1-dev \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "a serene mountain landscape at sunset",
      "width": 1024,
      "height": 576
    }'
  ```

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

  API_BASE = "https://api.krea.ai"
  API_TOKEN = "your-api-token"

  response = requests.post(
      f"{API_BASE}/generate/image/bfl/flux-1-dev",
      headers={
          "Authorization": f"Bearer {API_TOKEN}",
          "Content-Type": "application/json"
      },
      json={
          "prompt": "a serene mountain landscape at sunset",
          "width": 1024,
          "height": 576
      }
  )

  job = response.json()
  print(f"Job ID: {job['job_id']}")
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      apiBase := "https://api.krea.ai"
      apiToken := "your-api-token"

      payload := map[string]interface{}{
          "prompt": "a serene mountain landscape at sunset",
          "width":  1024,
          "height": 576,
      }

      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", apiBase+"/generate/image/bfl/flux-1-dev", bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer "+apiToken)
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      var job map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&job)
      fmt.Printf("Job ID: %s\n", job["job_id"])
  }
  ```
</CodeGroup>

## Pricing

For per-model prices, see [krea.ai/features/api ↗](https://krea.ai/features/api). Every model has a fixed per-generation price determined by your request parameters (resolution, quality, audio, duration, style references, etc.).

## How API Billing Works

API and MCP usage draws from a **separate USD balance** on your workspace — independent from the compute units used by the Krea web app. API access must be enabled on your workspace before you can use API keys; if it isn't, contact [support@krea.ai ↗](mailto:support@krea.ai).

<Check>
  Failed and cancelled jobs are not billed. You only pay for completed jobs.
</Check>

### When your balance runs out

In-flight jobs finish normally. New API requests are rejected with **HTTP 402 Payment Required**:

```json theme={null}
{
  "message": "Your API balance is separate from your workspace compute balance. Please top up your API balance to continue using the API."
}
```

Top up at [krea.ai/app/api/](https://krea.ai/app/api/) to resume. There is no public endpoint for checking your balance programmatically — monitor it in-app.

## Adding API Balance

Add funds at [krea.ai/app/api/](https://krea.ai/app/api/). Only workspace **owners** can add API balance.

* **Preset amounts:** \$10, \$25, \$50, \$100
* **Custom amount:** \$5 minimum, \$10,000 maximum
* Paid via Stripe Checkout; balance applies immediately on success

## Tracking Usage

Recent spend is shown on the API balance card at [krea.ai/app/api/](https://krea.ai/app/api/) under "API cost in the last 7 days."

## Enterprise

<Info>
  Higher-volume customers can be invoiced monthly on Net 30 terms instead of prepaying. Contact [sales@krea.ai ↗](mailto:sales@krea.ai) to discuss enterprise billing.
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="Interactive Playground" icon="rocket" href="/developers/interactiveexample">
    Make your first API request
  </Card>

  <Card title="Model APIs" icon="book-open" href="/api-reference/image/flux">
    Explore all available endpoints
  </Card>

  <Card title="Job Lifecycle" icon="cube" href="/developers/job-lifecycle">
    Understand job states and polling
  </Card>

  <Card title="Rate Limits" icon="gauge" href="/developers/rate-limits">
    Understand API limits by plan tier
  </Card>
</CardGroup>
