CLOUDFLARE_GATEWAY_HOST=https://gateway.ai.cloudflare.com
CLOUDFLARE_GATEWAY_ENDPOINT=/v1/e1a1737083ffd849ad2638b7e6069dec/lin/compat
CLOUDFLARE_GATEWAY_API_KEY=
CLOUDFLARE_GATEWAY_MODEL=google/gemini-2.0-flash


ai-sdk? this fails with a vague internal server error
cf-aig-custom-cost to no avail

v1 and v1-preview data plane API version (in azure) for ai gateway? Currently it breaks - unable to find resource (I assume url changes)v1 is the new GA version for a while now and the azure adapter in cercel ai sdk now defaults to it as well, breaking any usage relying on defaults
google-genai Python SDK. Since the SDK's resumable upload protocol automatically attempts to connect directly to generativelanguage.googleapis.com for the data transfer phase (Step 2), I applied a monkey patch to the SDK to intercept the upload_url and rewrite the hostname to my Cloudflare Gateway endpoint.400 Bad Request indicating that the data received is significantly larger (almost double) than the expected file size.Transfer-Encoding: chunked stream sent by the Python httpx client, possibly causing data duplication or incorrect packet retries.Current size ~10MB is nearly double the Expected ~5.5MB.)google-genai (using httpx).client._api_client.upload_file to replace googleapis.com with the Cloudflare Gateway URL.9a6803f82f942a86-LAXai-gateway-provider along with examples of using AI SDK with BYOK/Unified Billingai-sdkinternal server errorcf-aig-custom-costv1v1v1-previewgoogle-genaigoogle-genaigenerativelanguage.googleapis.comupload_url400 Bad RequestTransfer-Encoding: chunkedhttpxhttpxCurrent sizeExpectedclient._api_client.upload_filegoogleapis.com9a6803f82f942a86-LAXai-gateway-provider const openai = createOpenAICompatible({
name: 'cloudflare-gateway',
headers: { "cf-aig-authorization": `Bearer ${process.env.CLOUDFLARE_AI_TOKEN}` },
baseURL:`https://gateway.ai.cloudflare.com/v1/${process.env.CLOUDFLARE_ACCOUNT_ID}/${process.env.CLOUDFLARE_GATEWAY_NAME}/compat`,
includeUsage: true,
supportsStructuredOutputs: true
});{
"code": 400,
"message": "Can not finalize upload. Current size is 10085593. Expected final size is 5556955.",
"status": "Bad Request"
}