codai docs
API reference

Auth API (OIDC)

The public integrator surface of auth.codai.ro: discovery, authorization code + PKCE, device flow, tokens, logout and /connect/key.

auth.codai.ro is a standard OpenID Provider; read /.well-known/openid-configuration first and let your OIDC library drive the rest. The one codai-specific endpoint is GET /connect/key: exchange the access token for a scoped inference key (base_url: https://ai.codai.ro/v1). Only the endpoints an integrator calls are listed — the login/consent UI, account API and native app routes are first-party internals. OIDC errors are { "error", "error_description" }. Flow walkthrough: connect flow, scopes: scopes.

GET
/.well-known/openid-configuration

Response Body

application/json

curl -X GET "https://example.com/.well-known/openid-configuration"
{  "issuer": "https://auth.codai.ro",  "authorization_endpoint": "http://example.com",  "token_endpoint": "http://example.com",  "userinfo_endpoint": "http://example.com",  "jwks_uri": "http://example.com",  "introspection_endpoint": "http://example.com",  "revocation_endpoint": "http://example.com",  "device_authorization_endpoint": "http://example.com",  "end_session_endpoint": "http://example.com",  "registration_endpoint": "http://example.com",  "response_types_supported": [    "string"  ],  "grant_types_supported": [    "string"  ],  "token_endpoint_auth_methods_supported": [    "string"  ],  "scopes_supported": [    "string"  ],  "claims_supported": [    "string"  ],  "code_challenge_methods_supported": [    "S256"  ],  "acr_values_supported": [    "string"  ],  "subject_types_supported": [    "string"  ],  "id_token_signing_alg_values_supported": [    "string"  ],  "backchannel_logout_supported": true}
GET
/jwks

Response Body

application/json

curl -X GET "https://example.com/jwks"
{  "keys": [    {      "kty": "RSA",      "kid": "string",      "use": "sig",      "alg": "RS256",      "n": "string",      "e": "string"    }  ]}
GET
/auth

Query Parameters

response_type*"code"

Must be code.

Value in

  • "code"
client_id*string

Registered client identifier.

redirect_uri*string

One of the client's registered redirect URIs (exact match).

Formaturi
scope*string

Space-separated scopes; must include openid.

state?string

Opaque CSRF value echoed back on the redirect. Strongly recommended.

code_challenge*string

BASE64URL(SHA-256(code_verifier)) — PKCE is required for every client.

code_challenge_method*"S256"

Only S256 is supported.

Value in

  • "S256"
nonce?string

Replay protection echoed into the ID token.

prompt?string

Standard OIDC prompt values (login, consent, none, select_account).

acr_values?string

Requested authentication context; passkey/mfa trigger step-up.

resource?string

RFC 8707 resource indicator. https://ai.codai.ro/mcp yields a JWT access token with the mcp scope.

Formaturi
mode?"signup"

codai extension — signup opens the sign-up form directly.

Value in

  • "signup"
ref?string

codai extension — referral code (codai.ro/r/<username>, 3–20 chars [A-Za-z0-9_]) pre-filled on sign-up.

Match^[A-Za-z0-9_]{3,20}$
lang?string

UI language of the login pages. Defaults from the NEXT_LOCALE cookie, then Accept-Language.

Value in

  • "ro"
  • "en"

Response Body

text/html

curl -X GET "https://example.com/auth?response_type=code&client_id=metu&redirect_uri=http%3A%2F%2Fexample.com&scope=openid+email+profile+inference+keys%3Amanage&code_challenge=string&code_challenge_method=S256"
Empty
POST
/device/auth

Request Body

application/x-www-form-urlencoded

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/device/auth" \  -H "Content-Type: application/x-www-form-urlencoded" \  -d 'client_id=codai-cli'
{  "device_code": "string",  "user_code": "BCDF-GHJK",  "verification_uri": "https://auth.codai.ro/device",  "verification_uri_complete": "http://example.com",  "expires_in": 0,  "interval": 5}
POST
/token

Authorization

clientSecretBasic
AuthorizationBasic <token>

client_secret_basic client authentication. client_secret_post and private_key_jwt go in the form body instead; public clients send only client_id.

In: header

Request Body

application/x-www-form-urlencoded

TypeScript Definitions

Use the request body type in TypeScript.

Form-encoded body. Fields depend on grant_type; client credentials depend on the client's authentication method.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/token" \  -H "Content-Type: application/x-www-form-urlencoded" \  -d 'grant_type=authorization_code'
{  "access_token": "string",  "token_type": "Bearer",  "expires_in": 3600,  "scope": "string",  "id_token": "string",  "refresh_token": "string"}
POST
/token/introspection

Authorization

clientSecretBasic
AuthorizationBasic <token>

client_secret_basic client authentication. client_secret_post and private_key_jwt go in the form body instead; public clients send only client_id.

In: header

Request Body

application/x-www-form-urlencoded

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/token/introspection" \  -H "Content-Type: application/x-www-form-urlencoded" \  -d 'token=string'
{  "active": true,  "scope": "string",  "client_id": "string",  "sub": "string",  "token_type": "string",  "exp": 0,  "iat": 0,  "iss": "http://example.com",  "aud": "string",  "jti": "string"}
POST
/token/revocation

Authorization

clientSecretBasic
AuthorizationBasic <token>

client_secret_basic client authentication. client_secret_post and private_key_jwt go in the form body instead; public clients send only client_id.

In: header

Request Body

application/x-www-form-urlencoded

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/token/revocation" \  -H "Content-Type: application/x-www-form-urlencoded" \  -d 'token=string'
Empty
GET
/me

Authorization

bearerAuth
AuthorizationBearer <token>

OAuth access token issued by /token (used by /me and /connect/key).

In: header

Response Body

application/json

application/json

curl -X GET "https://example.com/me"
{  "sub": "string",  "email": "[email protected]",  "email_verified": true,  "name": "string",  "picture": "http://example.com"}
GET
/session/end

Query Parameters

id_token_hint?string

The ID token previously issued to this client; identifies the session and client.

post_logout_redirect_uri?string

Registered post-logout redirect URI of the client.

Formaturi
state?string

Opaque value appended to the post-logout redirect.

client_id?string

Required when id_token_hint is absent and a post_logout_redirect_uri is given.

ui_locales?string

Standard OIDC parameter; the codai UI reads ?lang=ro|en instead.

Response Body

text/html

text/html

curl -X GET "https://example.com/session/end"
"string"
GET
/connect/key

Authorization

bearerAuth
AuthorizationBearer <token>

OAuth access token issued by /token (used by /me and /connect/key).

In: header

Header Parameters

X-Codai-Device-Name?string

First-party clients only — label (≤ 60 chars) for the per-device key; defaults to Desktop.

Lengthlength <= 60

Response Body

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/connect/key"
{  "api_key": "codai_xxxxxxxxxxxxxxxxxxxxxxxx",  "api_key_id": "b0dd218e-3bcf-4bdb-a1e3-0689d60a8afd",  "base_url": "https://ai.codai.ro/v1",  "model": "codai",  "already_issued": true}
OPTIONS
/connect/key

Header Parameters

Origin?string
Formaturi

Response Body

application/json

curl -X OPTIONS "https://example.com/connect/key"
Empty
GET
/health

Response Body

application/json

curl -X GET "https://example.com/health"
{  "ok": true}
GET
/health/ready

Response Body

application/json

application/json

curl -X GET "https://example.com/health/ready"
{  "ok": true,  "checks": {    "db": {      "ok": true,      "error": "string"    }  }}