Skip to content

feat: images.generate (AI image generation), generation credits in usage — 0.2.0 - #1

Merged
facundofarias merged 1 commit into
mainfrom
feat/generate-image
Oct 30, 2026
Merged

facundofarias merged 1 commit into
mainfrom
feat/generate-image

Conversation

@facundofarias

Copy link
Copy Markdown
Member

Summary

Adds AI image generation to the Python SDK (API: POST /v1/images/generate, live since 2026-10-30).

  • pv.images.generate(prompt, model=, folder=, visibility=, expires_in=, sign_expires_in=) on the sync and async clients. Returns the image plus ["generation"] (model, credits_charged, credits_remaining).
  • Never retried after a 5xx/network error (already how POST works here), so a lost response cannot spend credits twice. 429 is retried: the API refunds before returning it.
  • Types: GeneratedImage, Generation, GenerationUsage; Usage gains generation; Image gains optimized_url.
  • README, version 0.2.0.

CI

spec-coverage fetches the live OpenAPI spec and fails on any operation the SDK neither wraps nor ignores. generate_image is now covered. The live spec had also gained dashboard_delete_image, start_checkout and open_billing_portal since the last run (Oct 26), which would have turned the next scheduled run (Monday) red regardless of this feature. I added them to IGNORED on purpose: a dashboard-session endpoint, and billing (a person pays or cancels; not an SDK flow). Say if you'd rather wrap billing.

Verification

mypy clean; pytest 23 passed (6 new: request body/headers, omitted options, credit-error code, no retry after 5xx, usage credits, async); check_spec_coverage.py passes against the live spec (14 covered, 14 ignored).

Release

Tag-triggered (v0.2.0 → PyPI trusted publishing); not tagged yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_019sMZVurbKqZ6zsbUYCsLJn

… usage, 0.2.0

- images.generate(prompt, model=, folder=, visibility=, expires_in=,
  sign_expires_in=) on the sync and async clients -> POST /v1/images/generate.
  Returns the image plus ["generation"] (model, credits_charged,
  credits_remaining). Never retried after a 5xx/network error, so a lost response
  cannot spend credits twice.
- Types: GeneratedImage, Generation, GenerationUsage; Usage gains generation;
  Image gains optimized_url.
- spec-coverage: generate_image is now covered. The live spec had also gained
  dashboard_delete_image, start_checkout and open_billing_portal, which would have
  turned the next scheduled run red; they are ignored on purpose (dashboard
  session / a person pays).
- README documents it; version 0.2.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019sMZVurbKqZ6zsbUYCsLJn
@facundofarias
facundofarias merged commit 6c0440f into main Oct 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant