Get started
Quickstart
Create a key and run your first model.
This guide takes you from a new API key to a finished image. You can follow it in TypeScript, Python or plain cURL.
Prerequisites
- An Astorie account with access to the API console
- Funds in your API wallet. A job is refused if the wallet can't cover it.
- Node.js 20+ or Python 3.10+. For cURL you also need
jqanduuidgen.
1. Create an API key
In the console, open API keys and create a key with at least
jobs:createandjobs:read. Copy it right away: the full key is shown once.2. Install a client
Skip this step if you are using cURL.
npm install @astorie/client@0.1.0-beta.13. Set your key
Both clients and the CLI read these two variables.
Terminal export ASTORIE_API_KEY="ast_gw_..." export ASTORIE_BASE_URL="https://astorie.ai/api/gateway"4. Run a model
run()submits the job and polls it until it finishes.maxChargeAmountis the most you are willing to pay for this job, in USD. If the price is higher, the job is refused and nothing is charged.import { Astorie } from "@astorie/client"; const client = new Astorie(); const input = { prompt: "A red chair in a sunlit studio", aspect_ratio: "1:1", resolution: "1K", output_format: "png", }; const { job } = await client.run("google/nano-banana-2", input, { maxChargeAmount: "1.000000", }); if (job.status === "succeeded") { console.log(job.output.assets[0].url); } else { console.log(job.status, job.error); }5. Check the result
A finished job lists its files in
output.assets. Each asset has aurlyou can download without an API key. Results are kept for at least 7 days, so save anything you want to keep.Finished job (trimmed) { "id": "job_3k7qz2m5x4rbd6wn2yhv7tcl4a", "status": "succeeded", "output": { "availability": "available", "assets": [ { "id": "file_7m2qk4zt6wbx3rn5yd2hc4vlaq", "type": "image", "mime_type": "image/png", "url": "https://s3.astorie.ai/req/7a1e0c55/0.png", "width": 1024, "height": 1024 } ] }, "billing": { "state": "settled", "charged_amount": "0.080000" } }