Hi, @Zack, I am having the same issue... Have you managed to solve the bug/error here?
Hi, @Zack, I am having the same issue... Have you managed to solve the bug/error here?
cache_control is being passed quite right for anthropic when using the openai compat endpoint
user key to idenitify requests for different users



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 defaultscache_controlCLOUDFLARE_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-flashai-sdkinternal server errorcf-aig-custom-costv1v1v1-previewexport function buildAIGatewayHeaders(
env: SharedHonoEnv,
headers?: LLMHeaders
): Record<string, string> {
const metadata: Record<string, string> = {};
// Allowlist: only include specific headers we want to pass to AIGateway
if (headers?.userToken) {
metadata.userToken = headers.userToken;
}
if (headers?.accountToken) {
metadata.accountToken = headers.accountToken;
}
if (headers?.requestId) {
metadata.requestId = headers.requestId;
}
const aigHeaders = {
"cf-aig-authorization": `Bearer ${env.CLOUDFLARE_AI_GATEWAY_API_KEY}`,
"cf-aig-metadata": JSON.stringify(metadata),
};
return aigHeaders;
} 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
});