Skip to content

Update AI types#6535

Merged
danlapid merged 3 commits into
cloudflare:mainfrom
samscott89:sscott/ai-types
Apr 10, 2026
Merged

Update AI types#6535
danlapid merged 3 commits into
cloudflare:mainfrom
samscott89:sscott/ai-types

Conversation

@samscott89

@samscott89 samscott89 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor
  • Add types for gemma-4
  • Format ai.d.ts with prettier Removed from PR
  • Refactor run interface to use overloads -- easier to read and easier to split input/output types
  • Remove per-model AsyncBatch types and use a new run overload -- decrease the file size and improve types when not using batch Removed from PR

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@samscott89

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Apr 8, 2026
@samscott89 samscott89 marked this pull request as ready for review April 8, 2026 22:18
@samscott89 samscott89 requested a review from a team as a code owner April 8, 2026 22:18
@samscott89 samscott89 requested a review from edmundhung April 8, 2026 22:18
@samscott89 samscott89 requested review from a team as code owners April 8, 2026 22:20
Comment thread types/generated-snapshot/experimental/index.d.ts Outdated

@JoaquinGimenez1 JoaquinGimenez1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread types/defines/ai.d.ts
…mma-4

Add overload-based run() signatures for better type inference:
- Batch request (queueRequest: true) -> AsyncResponse
- Raw response (returnRawResponse: true) -> Response
- WebSocket (websocket: true) -> Response
- Streaming (stream: true in inputs) -> ReadableStream
- Normal -> model-specific output type
- Unknown model (gateway fallback) -> Record<string, unknown>

The gateway fallback allows AI Gateway models (e.g. 'google/nano-banana')
to be called without type errors while preserving full type safety for
known Cloudflare AI models.

Also adds gemma-4-26b-a4b-it model types and type-check tests.
Comment thread types/generated-snapshot/latest/index.d.ts Outdated
@codspeed-hq

codspeed-hq Bot commented Apr 9, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 12.54%

❌ 1 regressed benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
Encode_ASCII_256[TextEncoder][0/0/256] 2.7 ms 3.1 ms -12.54%

Comparing samscott89:sscott/ai-types (312fda3) with main (9dbd5fa)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@danlapid danlapid merged commit a8cbb95 into cloudflare:main Apr 10, 2026
16 of 17 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.

5 participants