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.
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.
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
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.
Copy
Ask AI
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 }'
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.
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.