Send chat requests with OAuth
Use an approved ShareAI OAuth access token for customer-funded chat completions and handle token expiry, consent and account boundaries.
On this page
Choose this path when a customer has authorized your application to use their selected ShareAI account. First complete authorization code with PKCE and obtain a grant that includes surcharge.
https://api.shareai.now/api/v1/chat/completionsRun inference under the customer’s accepted application agreement.
- Base URL
https://api.shareai.now- Authentication
- Bearer OAuth access token
- Required scope
surcharge
cURL
curl --fail-with-body https://api.shareai.now/api/v1/chat/completions \
-H "Authorization: Bearer $SHAREAI_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data '{"model":"MODEL_IDENTIFIER","messages":[{"role":"user","content":"Hello!"}],"stream":false}'
The access token goes in the Bearer header#
The chat endpoint and request body are the same as the API-key flow. The difference is the credential and its authorization lifecycle. A refresh token is sent only to the token endpoint; an ID token is used only for validated application sign-in.
Who pays and which plan applies?#
The accepted grant identifies the selected personal or organization account, application and usage plan. The service determines those values from the authorization. Do not send a payer ID, builder fee or another client’s subject in the chat body to change billing.
Renew access without losing consent#
When the access token expires, use the refresh flow on your backend and store the replacement refresh token. When the grant is revoked or new consent is required, reconnect the customer through the browser flow.
Failure handling#
| Result | Action |
|---|---|
401 consent_required | Ask the customer to reconnect if the authorization is no longer valid. |
403 | Check granted inference permission and allowed model/provider access. |
429 | Respect Retry-After and your application/account limits. |
503 temporarily_unavailable | Show a temporary service error; do not tell the customer that consent was revoked. |
Last updated September 15, 2026