Exchange authorization code for API key

Exchange an authorization code from the PKCE flow for a user-controlled API key

Request

This endpoint expects an object.
codestringRequired
The authorization code received from the OAuth redirect
code_verifierstringOptional

The code verifier if code_challenge was used in the authorization request

code_challenge_methodenumOptional
The method used to generate the code challenge
Allowed values:

Response

Successfully exchanged code for an API key
keystring
The API key to use for OpenRouter requests
user_idstringOptional
User ID associated with the API key

Errors