{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../../src/providers/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE9C,kCAAkC;AAClC,eAAO,MAAM,8BAA8B,gFACmC,CAAC;AAE/E,8FAA8F;AAC9F,eAAO,MAAM,qCAAqC,gGAC4C,CAAC;AAE/F,oFAAkF;AAClF,eAAO,MAAM,qCAAqC,gGAC4C,CAAC;AAE/F,4CAA0C;AAC1C,eAAO,MAAM,wCAAwC,mGAC4C,CAAC;AAElG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAWlE","sourcesContent":["import type { Api, Model } from \"../types.ts\";\n\n/** Workers AI direct endpoint. */\nexport const CLOUDFLARE_WORKERS_AI_BASE_URL =\n\t\"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1\";\n\n/** AI Gateway Unified API. https://developers.cloudflare.com/ai-gateway/usage/unified-api/ */\nexport const CLOUDFLARE_AI_GATEWAY_COMPAT_BASE_URL =\n\t\"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat\";\n\n/** AI Gateway → OpenAI passthrough. Used until /compat supports /v1/responses. */\nexport const CLOUDFLARE_AI_GATEWAY_OPENAI_BASE_URL =\n\t\"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai\";\n\n/** AI Gateway → Anthropic passthrough. */\nexport const CLOUDFLARE_AI_GATEWAY_ANTHROPIC_BASE_URL =\n\t\"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic\";\n\nexport function isCloudflareProvider(provider: string): boolean {\n\treturn provider === \"cloudflare-workers-ai\" || provider === \"cloudflare-ai-gateway\";\n}\n\n/** Substitute `{VAR}` placeholders in a Cloudflare baseUrl from process.env. */\nexport function resolveCloudflareBaseUrl(model: Model<Api>): string {\n\tconst url = model.baseUrl;\n\tif (!url.includes(\"{\")) return url;\n\tconst baseUrl = url.replace(/\\{([A-Z_][A-Z0-9_]*)\\}/g, (_match, name: string) => {\n\t\tconst value = process.env[name];\n\t\tif (!value) {\n\t\t\tthrow new Error(`${name} is required for provider ${model.provider} but is not set.`);\n\t\t}\n\t\treturn value;\n\t});\n\treturn baseUrl;\n}\n"]}