# AI Gateway Observe and control your AI applications > Links below point directly to Markdown versions of each page. Any page can also be retrieved as Markdown by sending an `Accept: text/markdown` header to the page's URL without the `index.md` suffix (for example, `curl -H "Accept: text/markdown" https://cloudflaredoc.ubitools.com/ai-gateway/`). > > For other Cloudflare products, see the [Cloudflare documentation directory](https://cloudflaredoc.ubitools.com/llms.txt). ## Overview - [Cloudflare AI Gateway](https://cloudflaredoc.ubitools.com/ai-gateway/index.md): 通过 AI Gateway 提供分析、缓存、速率限制和模型回退功能,观察并控制 AI 应用。 ## 快速入门 - [快速入门](https://cloudflaredoc.ubitools.com/ai-gateway/get-started/index.md): 设置 AI Gateway 并发送第一个请求,以观察和控制 AI API 流量。 ## 模型 - [模型](https://cloudflaredoc.ubitools.com/ai/models/index.md): 浏览 AI Gateway 提供的 AI 模型,包括来自 OpenAI、Anthropic 和 Google 的模型。 ## 使用 AI Gateway - [使用 AI Gateway](https://cloudflaredoc.ubitools.com/ai-gateway/usage/index.md): 使用统一 API、提供商原生端点或 WebSockets 将 AI 应用连接到 AI Gateway。 - [统一 API(OpenAI 兼容)](https://cloudflaredoc.ubitools.com/ai-gateway/usage/chat-completion/index.md): 通过 AI Gateway 上的单个 OpenAI 兼容端点,向多个 AI 提供商发送请求。 - [Anthropic](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/anthropic/index.md): 通过 AI Gateway 路由 Anthropic API 请求,实现可观测性和控制。 - [Azure OpenAI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/azureopenai/index.md): 通过 AI Gateway 路由 Azure OpenAI 请求,实现可观测性和控制。 - [Baseten](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/baseten/index.md): 通过 AI Gateway 路由 Baseten 模型推理请求,实现可观测性和控制。 - [Amazon Bedrock](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/bedrock/index.md): 通过 AI Gateway 路由 Amazon Bedrock 请求,实现可观测性和控制。 - [Cartesia](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/cartesia/index.md): 通过 AI Gateway 路由 Cartesia 文本转语音请求,实现可观测性和控制。 - [Cerebras](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/cerebras/index.md): 通过 AI Gateway 路由 Cerebras 推理请求,实现可观测性和控制。 - [Cohere](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/cohere/index.md): 通过 AI Gateway 路由 Cohere API 请求,实现可观测性和控制。 - [Deepgram](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/deepgram/index.md): 通过 AI Gateway 路由 Deepgram 语音转文本和文本转语音请求,实现可观测性和控制。 - [DeepSeek](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/deepseek/index.md): 通过 AI Gateway 路由 DeepSeek API 请求,实现可观测性和控制。 - [ElevenLabs](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/elevenlabs/index.md): 通过 AI Gateway 路由 ElevenLabs 文本转语音请求,实现可观测性和控制。 - [Fal AI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/fal/index.md): 通过 AI Gateway 路由 Fal AI 生成式媒体请求,实现可观测性和控制。 - [Google AI Studio](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/google-ai-studio/index.md): 通过 AI Gateway 路由 Google AI Studio 和 Gemini 请求,实现可观测性和控制。 - [xAI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/grok/index.md): 通过 AI Gateway 路由 xAI (Grok) API 请求,实现可观测性和控制。 - [Groq](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/groq/index.md): 通过 AI Gateway 路由 Groq API 请求,实现可观测性和控制。 - [HuggingFace](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/huggingface/index.md): 通过 AI Gateway 路由 HuggingFace Inference API 请求,实现可观测性和控制。 - [Ideogram](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/ideogram/index.md): 通过 AI Gateway 路由 Ideogram 图像生成请求,实现可观测性和控制。 - [Mistral AI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/mistral/index.md): 通过 AI Gateway 路由 Mistral AI 请求,实现可观测性和控制。 - [OpenAI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/openai/index.md): 通过 AI Gateway 路由 OpenAI API 请求,实现可观测性和控制。 - [OpenRouter](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/openrouter/index.md): 通过 AI Gateway 路由 OpenRouter API 请求,实现可观测性和控制。 - [Parallel](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/parallel/index.md): 通过 AI Gateway 路由 Parallel API 请求,实现可观测性和控制。 - [Perplexity](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/perplexity/index.md): 通过 AI Gateway 路由 Perplexity API 请求,实现可观测性和控制。 - [Replicate](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/replicate/index.md): 通过 AI Gateway 路由 Replicate API 请求,实现可观测性和控制。 - [Google Vertex AI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/vertex/index.md): 通过 AI Gateway 路由 Google Vertex AI 请求,实现可观测性和控制。 - [Workers AI](https://cloudflaredoc.ubitools.com/ai-gateway/usage/providers/workersai/index.md): 通过 AI Gateway 路由 Workers AI 请求,实现分析、缓存和速率限制。 - [REST API](https://cloudflaredoc.ubitools.com/ai-gateway/usage/rest-api/index.md): 通过 Cloudflare API 调用第三方和 Workers AI 模型,并使用 AI Gateway 的日志记录、缓存和速率限制等功能。 - [通用端点(已弃用)](https://cloudflaredoc.ubitools.com/ai-gateway/usage/universal/index.md): 通过单个 AI Gateway 端点将请求路由到任何 AI 提供商,支持回退和重试。 - [网页搜索](https://cloudflaredoc.ubitools.com/ai-gateway/usage/web-search/index.md): 通过 AI Gateway 使用提供商原生的网页搜索工具,或通过其代理端点访问 Perplexity 和 Parallel 等以搜索为主的提供商。 - [WebSockets API](https://cloudflaredoc.ubitools.com/ai-gateway/usage/websockets-api/index.md): 通过 AI Gateway 使用持久 WebSocket 连接,实现实时和非实时 AI 交互。 - [Non-realtime WebSockets API(非实时 WebSockets API)](https://cloudflaredoc.ubitools.com/ai-gateway/usage/websockets-api/non-realtime-api/index.md): 通过 AI Gateway 建立持久 WebSocket 连接以发送 AI 请求,无需实时流式传输。 - [Realtime WebSockets API](https://cloudflaredoc.ubitools.com/ai-gateway/usage/websockets-api/realtime-api/index.md): 通过 AI Gateway 连接到支持实时 WebSocket 交互的 AI 提供商。 - [Workers 绑定](https://cloudflaredoc.ubitools.com/ai-gateway/usage/worker-binding-methods/index.md): 带 AI Gateway 的 AI 绑定参考。使用 env.AI.run() 调用 Workers AI 和 第三方模型,访问 log ID,并使用 gateway 方法进行反馈、日志记录和 URL。 ## 功能 - [功能](https://cloudflaredoc.ubitools.com/ai-gateway/features/index.md): 探索 AI Gateway 功能,包括缓存、速率限制、Guardrails、动态路由和数据丢失防护。 - [缓存](https://cloudflaredoc.ubitools.com/ai-gateway/features/caching/index.md): 按请求覆盖缓存设置。 - [数据丢失防护 (DLP)](https://cloudflaredoc.ubitools.com/ai-gateway/features/dlp/index.md): 使用 Cloudflare DLP 检测引擎保护 AI Gateway 提示和响应中的敏感数据。 - [设置数据丢失防护 (DLP)](https://cloudflaredoc.ubitools.com/ai-gateway/features/dlp/set-up-dlp/index.md): 在 AI Gateway 上启用和配置 DLP 策略,以扫描提示和响应中的敏感数据。 - [动态路由](https://cloudflaredoc.ubitools.com/ai-gateway/features/dynamic-routing/index.md): 使用可视化界面或 JSON 配置,基于条件、配额和回退路由 AI Gateway 请求。 - [JSON 配置](https://cloudflaredoc.ubitools.com/ai-gateway/features/dynamic-routing/json-configuration/index.md): 使用 REST API 和 JSON 元素结构定义 AI Gateway 动态路由流程。 - [使用动态路由](https://cloudflaredoc.ubitools.com/ai-gateway/features/dynamic-routing/usage/index.md): 使用 OpenAI SDK 或 REST API 通过 AI Gateway 动态路由发送请求。 - [Guardrails](https://cloudflaredoc.ubitools.com/ai-gateway/features/guardrails/index.md): 评估 AI Gateway 提示和响应中的有害内容,并跨提供商执行安全策略。 - [设置 Guardrails](https://cloudflaredoc.ubitools.com/ai-gateway/features/guardrails/set-up-guardrail/index.md): 启用并配置 AI Gateway Guardrails,以标记或阻止提示和响应中的有害内容。 - [支持的模型类型](https://cloudflaredoc.ubitools.com/ai-gateway/features/guardrails/supported-model-types/index.md): 查看 AI Gateway Guardrails 评估哪些 AI 模型类型,包括文本生成、嵌入和未知模型。 - [使用注意事项](https://cloudflaredoc.ubitools.com/ai-gateway/features/guardrails/usage-considerations/index.md): 了解启用 AI Gateway Guardrails 时的延迟、可用性、语言支持和 Workers AI 使用情况。 - [速率限制](https://cloudflaredoc.ubitools.com/ai-gateway/features/rate-limiting/index.md): 使用固定或滑动速率限制控制 AI Gateway 流量,防止过度成本和可疑活动。 - [支出限制](https://cloudflaredoc.ubitools.com/ai-gateway/features/spend-limits/index.md): 在 AI Gateway 上设置基于成本的预算,按模型、提供商或用户或团队等自定义元数据维度控制支出。 - [Unified Billing](https://cloudflaredoc.ubitools.com/ai-gateway/features/unified-billing/index.md): 使用 Cloudflare 计费来支付和验证推理请求。 ## 集成 - [集成](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/index.md): 将 AI Gateway 与 Workers 绑定、Vercel AI SDK 和其他平台连接。 - [Agents](https://cloudflaredoc.ubitools.com/agents/index.md): 在 Cloudflare 上构建 AI 驱动的 Agents - [使用 AI Gateway 设置 Workers AI](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/aig-workers-ai-binding/index.md): 本指南将带你完成 Workers AI 项目的设置与部署。你将使用 Workers、AI Gateway 绑定(binding)以及大语言模型(LLM),在 Cloudflare 全球网络上部署第一个 AI 驱动的应用。 - [编码智能体](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/index.md): 通过 AI Gateway 路由 Claude Code、Claude Desktop、GitHub Copilot CLI、OpenAI Codex 和 Pi,实现可观测性、缓存、速率限制和成本跟踪。 - [Claude Code](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/claude-code/index.md): 使用 Cloudflare gateway 令牌,通过 AI Gateway 路由 Claude Code。 - [Claude Desktop](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/claude-desktop/index.md): 使用第三方推理设置和 Cloudflare gateway 令牌,通过 AI Gateway 路由 Claude Desktop。 - [GitHub Copilot CLI](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/github-copilot-cli/index.md): 使用 REST API 和 Unified Billing,通过 AI Gateway 路由 GitHub Copilot CLI。 - [OpenAI Codex](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/openai-codex/index.md): 使用指向 OpenAI 端点的自定义模型提供商,通过 AI Gateway 路由 OpenAI Codex。 - [Pi](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/coding-agents/pi/index.md): 使用内置的 Cloudflare AI Gateway 提供商,通过 AI Gateway 路由 Pi 编码智能体。 - [Vercel AI SDK](https://cloudflaredoc.ubitools.com/ai-gateway/integrations/vercel-ai-sdk/index.md): 使用 ai-gateway-provider 包,通过 AI Gateway 路由 Vercel AI SDK 请求。 ## 教程 - [教程](https://cloudflaredoc.ubitools.com/ai-gateway/tutorials/index.md): AI Gateway 分步教程,涵盖部署 Workers、连接提供商和构建 AI 应用。 - [使用 Workers AI 创建你的第一个 AI Gateway](https://cloudflaredoc.ubitools.com/ai-gateway/tutorials/create-first-aig-workers/index.md): 本教程引导你在 Cloudflare 仪表板上使用 Workers AI 创建第一个 AI Gateway。 - [通过 AI Gateway 使用 Pruna P-video](https://cloudflaredoc.ubitools.com/ai-gateway/tutorials/pruna-p-video/index.md): 了解如何通过 AI Gateway 在 Replicate 上调用 prunaai/p-video ## 更新日志 - [更新日志](https://cloudflaredoc.ubitools.com/ai-gateway/changelog/index.md): 跟踪 AI Gateway 的最新更新、新功能和修复。 ## 标头术语表 - [标头术语表](https://cloudflaredoc.ubitools.com/ai-gateway/glossary/index.md): 参考所有支持的 AI Gateway 标头,用于配置、自定义和管理 API 请求。 ## REST API 参考 - [REST API 参考](https://cloudflaredoc.ubitools.com/api/resources/ai_gateway/methods/list/index.md): 使用 Cloudflare REST API 以编程方式管理 AI Gateway 资源。 ## Evaluations - [Evaluations](https://cloudflaredoc.ubitools.com/ai-gateway/evaluations/index.md): 使用数据集、人工反馈和评估指标评估 AI Gateway 应用性能。 - [使用仪表板添加人工反馈](https://cloudflaredoc.ubitools.com/ai-gateway/evaluations/add-human-feedback/index.md): 在 Cloudflare 仪表板中使用点赞或点踩标注 AI Gateway 日志。 - [使用 API 添加人工反馈](https://cloudflaredoc.ubitools.com/ai-gateway/evaluations/add-human-feedback-api/index.md): 使用 Cloudflare API 为 AI Gateway 请求日志提交人工反馈。 - [使用 Worker Bindings 添加人工反馈](https://cloudflaredoc.ubitools.com/ai-gateway/evaluations/add-human-feedback-bindings/index.md): 使用 Worker 绑定以编程方式为 AI Gateway 评估提供人工反馈。 - [设置 Evaluations](https://cloudflaredoc.ubitools.com/ai-gateway/evaluations/set-up-evaluations/index.md): 创建数据集、选择评估器并为 AI Gateway 日志运行评估。 ## configuration - [已认证的 Gateway](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/authentication/index.md): 通过要求每个请求提供有效的授权令牌来增强安全性。 - [BYOK (Store Keys)](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/bring-your-own-keys/index.md): 在 AI Gateway 中安全存储 AI 提供商 API 密钥,并在 gateway 配置中引用它们。 - [自定义成本](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/custom-costs/index.md): 按请求覆盖默认或公开的模型成本。 - [自定义提供商](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/custom-providers/index.md): 为你的账户创建和管理自定义 AI 提供商。 - [回退](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/fallbacks/index.md): 在 AI Gateway 中指定模型或提供商回退,以处理请求失败并确保可靠性。 - [管理 gateway](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/manage-gateway/index.md): 使用仪表板或 API 创建、编辑和删除 AI Gateway 实例。 - [请求处理](https://cloudflaredoc.ubitools.com/ai-gateway/configuration/request-handling/index.md): 配置 AI Gateway 请求超时和重试,以实现可靠的 AI 提供商交互。 ## observability - [分析](https://cloudflaredoc.ubitools.com/ai-gateway/observability/analytics/index.md): 在仪表板中或通过 GraphQL 查看 AI Gateway 的请求、token、缓存、错误和费用指标。 - [成本](https://cloudflaredoc.ubitools.com/ai-gateway/observability/costs/index.md): 使用 AI Gateway 成本指标跟踪和估算跨 AI 提供商的基于 token 的成本。 - [自定义元数据](https://cloudflaredoc.ubitools.com/ai-gateway/observability/custom-metadata/index.md): 使用用户 ID 等自定义元数据标记 AI Gateway 请求,以改进日志过滤和分析。 - [日志记录](https://cloudflaredoc.ubitools.com/ai-gateway/observability/logging/index.md): 存储并检查 AI Gateway 请求日志,包括提示、响应、token、费用和 DLP 操作。 - [Workers Logpush](https://cloudflaredoc.ubitools.com/ai-gateway/observability/logging/logpush/index.md): 使用 Workers Logpush 将加密的 AI Gateway 日志导出到外部存储。 - [OpenTelemetry](https://cloudflaredoc.ubitools.com/ai-gateway/observability/otel-integration/index.md): 将 AI Gateway 跟踪 span 导出到兼容 OpenTelemetry 的后端,用于分布式跟踪和性能监控。 ## reference - [审计日志](https://cloudflaredoc.ubitools.com/ai-gateway/reference/audit-logs/index.md): 查看 AI Gateway 配置更改(如 gateway 创建、删除和更新)的审计日志条目。 - [限制](https://cloudflaredoc.ubitools.com/ai-gateway/reference/limits/index.md): 查看 AI Gateway 的 gateway、日志存储、缓存大小、元数据条目和 Logpush 作业限制。 - [定价](https://cloudflaredoc.ubitools.com/ai-gateway/reference/pricing/index.md): 查看 AI Gateway 定价,包括免费核心功能、持久日志存储限制和高级附加功能。 - [故障排除](https://cloudflaredoc.ubitools.com/ai-gateway/reference/troubleshooting/index.md): 解决常见的 AI Gateway 问题,包括身份验证错误、缺失日志和提供商连接问题。 ## 架构 - [架构](https://cloudflaredoc.ubitools.com/ai-gateway/demos/index.md): 探索将 AI Gateway 集成到基础设施中的参考架构和设计指南。