Skip to content

Expose native web search and image generation in the SDK#294

Merged
adambalogh merged 1 commit into
mainfrom
claude/sdk-image-gen-web-search-je9RZ
May 31, 2026
Merged

Expose native web search and image generation in the SDK#294
adambalogh merged 1 commit into
mainfrom
claude/sdk-image-gen-web-search-je9RZ

Conversation

@adambalogh
Copy link
Copy Markdown
Collaborator

Summary

The TEE gateway recently added an opt-in web_search flag and native Gemini image generation. This PR surfaces both capabilities through the SDK's LLM client (plus the LangChain adapter and CLI). No gateway changes are needed — this is purely client-side wiring.

Web search

Opt-in web_search flag, billed per search on top of token usage. Supported by OpenAI, Anthropic, Google, and xAI models; other providers ignore the flag.

  • LLM.chat() and LLM.completion() gain a web_search: bool = False argument that forwards web_search: true to the gateway when enabled.
  • LangChain adapter (OpenGradientChatModel) forwards it via both the constructor and per-call kwargs.
  • CLI chat/completion gain a --web-search flag.

Image generation ("nano banana")

  • Add GEMINI_2_5_FLASH_IMAGE, GEMINI_3_1_FLASH_IMAGE, and GEMINI_3_5_FLASH to the TEE_LLM enum.
  • Surface generated images as data: URIs on TextGenerationOutput.images (non-streaming) and StreamChunk.images (final stream chunk).
  • CLI decodes and writes generated images to disk (--image-output-dir) instead of dumping base64.

Images travel out-of-band and are not part of the signed TEE output hash, matching the gateway's existing contract (documented in the docstrings).

Supporting work

  • New examples: examples/llm_web_search.py and examples/llm_image_generation.py, both referenced in examples/README.md.
  • README + docstring updates (Key Features, new sections, model list).
  • Unit tests for payload forwarding (chat + completion) and image surfacing (non-streaming + streaming).

Verification

  • uv run pytest tests/131 passed
  • uv run mypy src and uv run mypy examples → clean
  • ruff format clean

https://claude.ai/code/session_015BV6hef5Ld82rbov858L58


Generated by Claude Code

The TEE gateway recently added an opt-in `web_search` flag and native
Gemini image generation. This surfaces both through the LLM client.

Web search:
- `LLM.chat` and `LLM.completion` gain a `web_search: bool = False` arg that
  forwards `web_search` to the gateway when enabled. Supported by OpenAI,
  Anthropic, Google, and xAI models; billed per search on top of tokens.
- LangChain adapter forwards `web_search` (constructor + per-call kwarg).
- CLI `chat`/`completion` gain a `--web-search` flag.

Image generation:
- Add `GEMINI_2_5_FLASH_IMAGE` and `GEMINI_3_1_FLASH_IMAGE` ("nano banana")
  plus `GEMINI_3_5_FLASH` to the `TEE_LLM` enum.
- Surface generated images on `TextGenerationOutput.images` (non-streaming)
  and `StreamChunk.images` (final stream chunk) as `data:` URIs.
- CLI saves generated images to disk (`--image-output-dir`) instead of
  dumping base64.

Adds examples (`llm_web_search.py`, `llm_image_generation.py`), README and
docstring updates, and unit tests for payload forwarding and image surfacing.
@adambalogh adambalogh merged commit ad65ae9 into main May 31, 2026
9 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.

2 participants