Skip to content

fix: keep slashes in model name for ai.run route - #2796

Open
gulybyte wants to merge 1 commit into
cloudflare:mainfrom
gulybyte:main
Open

fix: keep slashes in model name for ai.run route#2796
gulybyte wants to merge 1 commit into
cloudflare:mainfrom
gulybyte:main

Conversation

@gulybyte

@gulybyte gulybyte commented Aug 6, 2026

Copy link
Copy Markdown

Bug

ai.run() percent-encodes the / in the model slug, e.g. @cf/meta/llama-3.3-70b-instruct-fp8-fast becomes @cf%2Fmeta%2Fllama-.... The Workers AI endpoint /accounts/{id}/ai/run/{model} requires the model name with literal / separators, so every request fails with:

400 {"success":false,"errors":[{"code":7000,"message":"No route for that URI"}]}

Root cause

The path template tag used to build the route percent-encodes every path parameter (including /). Verified against the live API: the same request succeeds via curl and via client.post() with a plain string.

Fix

Build the route with a plain string so the model name keeps its slashes. account_id is a hex slug and safe as-is.

this._client.post(`/accounts/${account_id}/ai/run/${modelName}`, { body, ...options })

Tests

Added run: keeps / in model name unencoded — mocks fetch, asserts the full request URL contains the literal / separators. Prettier/eslint/tsc clean.

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