Skip to content

Update AI types#6535

Open
samscott89 wants to merge 3 commits intocloudflare:mainfrom
samscott89:sscott/ai-types
Open

Update AI types#6535
samscott89 wants to merge 3 commits intocloudflare:mainfrom
samscott89:sscott/ai-types

Conversation

@samscott89
Copy link
Copy Markdown

@samscott89 samscott89 commented Apr 8, 2026

  • 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
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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


1 out of 2 committers have signed the CLA.
✅ (samscott89)[https://github.com/samscott89]
@sam Scott
Sam Scott seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@samscott89
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Member

@JoaquinGimenez1 JoaquinGimenez1 left a comment

Choose a reason for hiding this comment

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

LGTM

…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.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will degrade performance by 10.72%

❌ 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_1024[TextEncoder][0/0/1024] 3.3 ms 3.7 ms -10.72%

Comparing samscott89:sscott/ai-types (730df77) with main (b4b73d8)

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.

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.

4 participants