Skip to content

Conversation

@daisyfaithauma
Copy link
Contributor

Summary

Screenshots (optional)

Documentation checklist

  • The documentation style guide has been adhered to.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

@daisyfaithauma daisyfaithauma requested review from a team, G4brym, kathayl and mchenco as code owners November 8, 2024 15:38
@github-actions github-actions bot added product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/s labels Nov 8, 2024
Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 files reviewed, 2 total issue(s) found.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 8, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 37827bf
Status: ✅  Deploy successful!
Preview URL: https://bab7b689.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://aig-authentication.cloudflare-docs-7ou.pages.dev

View logs

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 4 total issue(s) found.

daisyfaithauma and others added 4 commits November 8, 2024 15:48
api link

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
@kathayl
Copy link
Contributor

kathayl commented Nov 8, 2024

oh this is something we should definitely add to changelog. @daisyfaithauma can you do this?

@kathayl
Copy link
Contributor

kathayl commented Nov 8, 2024

@G4brym Two asks!

  1. Can you add steps on how to add authentication using API?
  2. Does authentication work if a user is not using a curl request? Can you add an example on how users can add authentication when using openai SDK or Vercel AI SDK or other library?

@G4brym
Copy link
Member

G4brym commented Nov 11, 2024

https://developers.cloudflare.com/api/operations/aig-config-update-gateway

curl --request PUT \
  --url https://api.cloudflare.com/client/v4/accounts/account_id/ai-gateway/gateways/my-gateway \
  --header 'Authorization: Bearer{token}' \
  --header 'Content-Type: application/json' \
  --data '{
  "cache_invalidate_on_update": true,
  "cache_ttl": 0,
  "collect_logs": true,
  "logpush": true,
  "authentication": true,
  "logpush_public_key": "my-logpush-key",
  "rate_limiting_interval": 0,
  "rate_limiting_limit": 0,
  "rate_limiting_technique": "fixed"
}'

vercel sdk

import { createOpenAI } from "@ai-sdk/openai";

const openai = createOpenAI({
  baseURL: "https://gateway.ai.cloudflare.com/v1/account-id/gateway/openai",
  headers: {
    "cf-aig-token": `Bearer {token}`,
  },
});

openai sdk

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://gateway.ai.cloudflare.com/v1/account-id/gateway/openai",
  defaultHeaders: {
    "cf-aig-token": `Bearer {token}`,
  },
});

@daisyfaithauma daisyfaithauma merged commit 0bd2818 into production Nov 19, 2024
13 checks passed
@daisyfaithauma daisyfaithauma deleted the aig-authentication branch November 19, 2024 12:43
harshil1712 pushed a commit that referenced this pull request Dec 3, 2024
* Initial authentication documentation

* Added links to authentication

* Update src/content/docs/ai-gateway/configuration/authentication.mdx

api link

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Update src/content/docs/ai-gateway/configuration/authentication.mdx

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Update src/content/docs/ai-gateway/get-started.mdx

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Update src/content/docs/ai-gateway/observability/logging/index.mdx

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>

* Update src/content/docs/ai-gateway/get-started.mdx

Co-authored-by: Jun Lee <[email protected]>

* Update src/content/docs/ai-gateway/get-started.mdx

Co-authored-by: Jun Lee <[email protected]>

* Update src/content/docs/ai-gateway/configuration/authentication.mdx

Co-authored-by: Jun Lee <[email protected]>

* Update authentication.mdx

* Update get-started.mdx

* Update index.mdx

* Update authentication.mdx

* Update get-started.mdx

* Update index.mdx

* added examples and changelog

* websockets changelog

* Update authentication.mdx

---------

Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: Jun Lee <[email protected]>
Co-authored-by: Kathy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge-yet product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants