OhMyGPT API
English
  • 中文
  • English
  • 日本語
OhMyGPT
OhMyGPT
English
  • 中文
  • English
  • 日本語
  1. OAuth开放API
  • Introduction to this site
  • Change log
  • OpenAI
    • Responses
      • Create model response
      • Get model response
      • Delete model response
      • Cancel response
      • List input items
    • Conversations
      • create conversation
      • Retrieve conversation
      • update conversation
      • delete conversation
      • Create items
      • list items
      • Retrieve item
      • Delete item
    • create completion
      POST
    • TTS text to speech
      POST
    • Embeddings
      POST
    • image generation
      POST
    • image editing
      POST
  • Store
    • List chat completions
      POST
    • Get chat completed
      POST
    • Deletion of chat completed
      POST
  • Claude
    • Anthropic native Completions enterprise commercial API
      POST
    • Anthropic native Messages API
      POST
    • Anthropic native Messages Token Count API
      POST
  • OAuth开放API
    • Introduction to Open OAuth API
    • User authorization page
      GET
    • Code display page
      GET
    • Apply for access_token
      POST
    • Read basic user information
      POST
    • Read user balance information
      POST
    • Charge user fees
      POST
    • Create a Stripe Checkout recharge order for the user
      POST
    • Create a Stripe Invoice recharge order for the user
      POST
    • Call other open APIs
      POST
    • Read user management token through OAuth Token
      POST
    • Update user management token through OAuth Token
      POST
  • other
    • search
      • Google Custom Search API
      • Google Search By Serper
    • Azure
      • Azure text-to-speech
      • Azure gets TTS voice list
  • Override rules
    • Create rules
    • Update rules
    • delete rule
    • Get rules
    • list rules
    • Batch enable/disable
    • Copy rules
    • test rules
    • Get statistics
    • Get restriction configuration
    • Check rule name
    • Batch delete
    • Export rules
    • Import rules
  • image generation
    • other
      • ND image generation API
    • Flux
      • Flux Schnell image generation
      • Flux Dev image generation
      • Flux Pro image generation
      • Flux Pro 1.1 image generation
      • Flux 1.1 Pro Ultura image generation
  • Storage service
    • File storage service
    • File upload
    • File information update
    • Delete files
    • User query (pagination)
    • User metadata query (by fileUinqueIds)
    • File download interface (Public file download)
    • File download interface (Private private file download)
    • Obtain public file metadata
  • API KEY management
    • Create new API Key
    • Modify API Key information
    • Query all API Keys of the user
    • Delete the specified API Key
    • Interface for querying user membership expiration date
    • User balance query interface
    • Query the current model magnification interface
  • Archive documents
    • Self-service invoicing system usage documentation
    • Telegram Bot usage documentation
    • Self-built Cloudflare Worker anti-generation tutorial
    • Claude Code forwarding service
    • CodeX forwarding service
    • Introduction to the new website
  • Model list
    GET
  1. OAuth开放API

Apply for access_token

line1
https://cn2us02.opapi.win
line1
https://cn2us02.opapi.win
POST
/api/v1/user/oauth/issue-token
The OAuth APP server requests the OAuth Access Token through its own client_id+client_secret and the code obtained from the user.
After getting the user's OAuth Token, you can call various open APIs to access the resources authorized by the user.
But you need to pay attention to the situation when the OAuth Token is revoked.
The user can revoke the authorization for your OAuth App at any time, in which case a 4xx error + a response in the following format will be returned:
{
    "statusCode": 401,
    "message": "Incorrect OhMyGPT OAuth token provided. Please try to re-authenticate with the OAuth provider.",
    "errorType": "oauth_invalid_token_error",
    "data": null
}
As long as the errorType is found to be oauth_invalid_token_error, it proves that the Token is invalid. You can discard the Token and ask the user to re-authorize it.
If you encounter an insufficient balance error:
{
    "statusCode": 402,
    "message": "User balance is insufficient, your request has been rejected, please recharge in time at https://www.ohmygpt.com/pay .",
    "errorType": "insufficient_balance_error",
    "data": null
}
The above error report indicates that the user's balance is insufficient. At this time, most of the user's API calling permissions will be restricted. It is recommended that the user go to the website to recharge to remove the restrictions.

请求参数

Body 参数application/x-www-form-urlencoded

返回响应

🟢200success
application/json
Body

请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://cn2us02.opapi.win/api/v1/user/oauth/issue-token' \
--data-urlencode 'client_id=6680e0785ffd0e948c705db7' \
--data-urlencode 'client_secret=TREAHK4hnqEmST4YjD8Ki8338HyrmEDc' \
--data-urlencode 'code=code'
响应示例响应示例
Successful Examples
{
    "statusCode": 200,
    "message": "Issue OAuth Token success",
    "data": {
        "user_id": "888",
        "client_id": "6681463833ebdbb2566d1def",
        "token": "omg-oat-v1-VVfxxxx4BG6xaxxxxrnS"
    }
}
修改于 2025-10-15 08:07:30
上一页
Code display page
下一页
Read basic user information
Built with