Skip to content

feat(ai): add Google image generation#37781

Open
opencode-agent[bot] wants to merge 2 commits into
v2from
google-images
Open

feat(ai): add Google image generation#37781
opencode-agent[bot] wants to merge 2 commits into
v2from
google-images

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Google.configure(...).image(modelID) backed by Gemini generateContent for current Nano Banana image models
  • filter interim thought: true image parts while preserving ordered candidate/part metadata, text boundaries, thought flags, and signatures without duplicating image bytes
  • reject unsupported imagen-* model IDs locally and use valid REST thinkingLevel enum literals
  • normalize token counts while preserving the complete raw Google usage payload, including serviceTier
  • include finish reasons, prompt feedback, safety details, and candidate context in no-image errors
  • preserve Google API-key/env auth and merged HTTP headers, query parameters, and body overlays

Tests

  • bun x prettier --check README.md src/protocols/google-images.ts test/image.test.ts test/provider/google-images.recorded.test.ts src/providers/google.ts
  • GOMAXPROCS=4 bun typecheck
  • bun run build
  • bun test test/image.test.ts --timeout 30000 --only-failures (6 passed)
  • bun test --timeout 30000 --only-failures (357 passed, 29 skipped)
  • RECORDED_PREFIX=google-images bun test test/provider/google-images.recorded.test.ts --timeout 30000 --only-failures (1 passed)
  • scanned the cassette against GOOGLE_GENERATIVE_AI_API_KEY and credential header names; no secret material is present

Live evidence

  • generated one 412,499-byte JPEG through the actual Google route
  • decoded and visually inspected the result: a centered blue circle on a white background, matching the prompt
  • verified JPEG format and 1024x1024 dimensions
  • retained the existing cassette because the request shape did not change; replay succeeds without re-recording

Limitations

  • this adapter supports Gemini generateContent image models only; Imagen uses a different API and is rejected locally
  • Google generateContent does not expose exact pixel dimensions or a requested image count, so portable size and count are rejected with typed invalid-request errors
  • output format is provider-selected; the returned inline-data MIME type is preserved
  • scope is single-shot direct Image.generate; no conversational continuation path is added

Requested by: @rekram1-node (Aiden Cline via Slack)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant