Gå til indhold
Log indStart gratis

API clients

Two small clients, one file each, no dependencies. They ask for the price first, cap the charge and keep the same request key when a call is retried.

Python

Python 3.10 or newer, standard library only. Save the file beside your program: pickshot.py

from pickshot import Pickshot

client = Pickshot(os.environ["PICKSHOT_API_KEY"])
request = {"model": "indigo", "prompt": "a red paper boat on a calm lake"}
quote = client.estimate("images", request)
result = client.create("images", request, max_credits=quote["credits"], idempotency_key="my-boat-001")

JavaScript

Node.js 22 or newer. Save the file beside your program. The declarations file gives TypeScript the types: pickshot.mjs · pickshot.d.mts

import { Pickshot } from "./pickshot.mjs";

const client = new Pickshot({ apiKey: process.env.PICKSHOT_API_KEY });
const request = { model: "indigo", prompt: "a red paper boat on a calm lake" };
const quote = await client.estimate("images", request);
const result = await client.create("images", request, { maxCredits: quote.credits, idempotencyKey: "my-boat-001" });

What both do

  • Read the models and their prices (models).
  • Ask for the price of an exact request (estimate), which never charges.
  • Create within a maximum charge you give (create), with one request key kept across retries.
  • Follow a job until it is over (wait), which never starts another one.

Make a key on the API page and keep it on your server, in an environment variable. Everything made through a key costs credits. Get an API key

Other ways in

  • The REST API is described in an OpenAPI file. OpenAPI description
  • Connect an AI assistant with MCP. MCP
  • Try any model in the browser with its price shown first. Playground

Spørgsmål

Are these packages on a package registry?

No. They are single files you download here. Nothing needs installing.

Do they cost anything?

The clients are free. Every generation they start costs credits at the API price.