Skip to main content
With this guide, you’ll learn how to manage your API tokens and create your first API calls. You can also find more examples in the Code Examples page.

Prerequisites

Generate an API token in your Krea API Token Management page. If you are not sure how to do this, you can read the API Keys & Billing.
Generate an API TokenYou’ll need to generate an API token to use the API.Include your token in all requests:
Authorization: Bearer your-token-secret

Interactive Playground

Let’s start with an example workflow: generating an image with Flux. Paste your API token into the playground below, run the code, and see the image generation output.
Try the interactive playground above to run this workflow directly in your browser. Below, we’ll break down each step so you can implement it in your own applications.
To find all available models, see the Model APIs page. You can find all model parameters and example API calls in there.

Understanding the API Call

Now let’s break down what each part of the above code does.

Step 1: Create an API Token

First, you’ll need to create an API token. Visit the API Keys & Billing page and click “Create New Token”. Give it a name and save the token securely: you’ll only see it once!
Security WarningNever commit your API tokens to version control or share them publicly. Treat them like passwords.
API Token Best Practices
  • Store tokens in environment variables (e.g. a .env file), never use it directly in code
  • Use different tokens for development and production
  • Rotate tokens regularly
  • Revoke tokens immediately if compromised
  • Use separate tokens for each application or service

Step 2: Generate an Image with Flux

The playground makes a POST request to /generate/image/bfl/flux-1-dev with your prompt and parameters. The API returns a job ID immediately—generation happens asynchronously.
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,
    "steps": 28
  }'
Example Response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued",
  "created_at": "2025-01-15T10:30:00.000Z"
}
Now, the image generation will start. While the image is generating, you can continuously get intermediate outputs by polling the job status, which we outline below.

Step 3: Poll for Results

What about webhooks?You can now set up custom webhooks for job updates. See our Webhooks guide to get started.
The Krea API provides intermediate generation outputs for some models. This is useful if you want to show the generation progress to the user. To get intermediate outputs, poll /jobs/{job_id} every 2 seconds until the job completes. Once the image is ready, you can use that image URL to create a video.
# Check job status
curl -X GET https://api.krea.ai/jobs/YOUR_JOB_ID \
  -H "Authorization: Bearer YOUR_API_TOKEN"
Example Completed Response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "created_at": "2025-01-15T10:30:00.000Z",
  "completed_at": "2025-01-15T10:30:25.000Z",
  "result": {
    "urls": [
      "https://krea.ai/generations/your-image.png"
    ]
  }
}
You can now use the image URL to view the generated image.
To learn about all possible job statuses and the complete job lifecycle, check out the Job Lifecycle page.

Next Steps