Skip to Content
APIAuthenticationOverview

API Authentication

Every request to the GPTfake API must be authenticated. The API supports two mechanisms: API keys (a bearer token, for server-side and research use) and OAuth 2.0 (for applications acting on behalf of other users). All traffic is HTTPS-only.

Bearer token

Pass your API key in the Authorization header on every request:

curl https://api.gptfake.com/v1/monitoring/chatgpt/metrics \ -H "Authorization: Bearer YOUR_API_KEY"

A missing or malformed token returns 401 Unauthorized. A valid token that lacks the scope for a resource returns 403 Forbidden.

Which method should I use?

Use caseMethod
Server-side scripts, research pipelines, dashboardsAPI key
A third-party app accessing data for its usersOAuth 2.0
Quick one-off curl / notebook explorationAPI key

Security basics

Treat API keys like passwords. Never commit them to source control, embed them in client-side code, or paste them into shared notebooks. Use environment variables and rotate keys regularly.

  • Send credentials only over HTTPS — the API rejects plain HTTP.
  • Scope keys to the minimum tier and permissions you need.
  • Rotate keys on a schedule and immediately if one is exposed.

Next steps