This page documents the Social Media Tools / SocialGPT-specific API surface.
This is intentionally separate from:
/docs/en/ai/openai/docs/en/ai/copilotAndroid screenshot Reply/Verify calls use the existing unversioned POST /api/ai/socialgpt/respond endpoint and personal ai.socialgpt bearer. Alongside context, user_prompt and request_mode, clients may submit one optional image_data_uri containing a complete JPEG, PNG or WebP data:image/...;base64,... screenshot (5 MiB decoded image maximum). The backend checks Base64, image header, MIME match and dimensions, then passes the actual image to the configured OpenAI model as input_image alongside the prompt. Malformed, empty or oversized image submissions return HTTP 422 without contacting OpenAI. A legacy has_screenshot flag alone is not visual input.
The one-shot image is processed for the user request, never stored in SocialGPT request logs or audit records. Do not include encoded pixels, screenshot text, secrets or raw provider responses in diagnostics. Android's ordinary MediaProjection consent still applies to capturing the visible screen; selecting an existing image through Android's file picker needs no live capture permission. The same endpoint and access checks remain in use. No API versioning is introduced.
Social Media Tools AI endpoints are intended for SocialGPT/browser-extension style traffic.
ai.socialgptai.client/keys/mineSocialGPT responds, status polling, and prefetch open/append/close first resolve the caller's account from the authenticated session or personal ai.socialgpt scoped bearer. Missing authentication returns HTTP 401 (error_code: socialgpt_unauthenticated); an unresolved/unlinked bearer that has been recorded for owner linking retains HTTP 409 (error_code: socialgpt_owner_link_required, pending_owner_link: true). A resolved account denied by the server-side SocialGPT feature policy returns HTTP 403 (error_code: socialgpt_feature_unavailable). These errors do not indicate whether a foreign prefetch session exists; the owner-isolated idempotent close behavior remains unchanged. Existing Chrome 1.2.18 request fields and the ai.client legacy scope alias remain compatible.
Operational diagnostics include the safe error code and can resolve the owner of valid ai.socialgpt bearer requests without logging credentials. A bearer header being present alone does not prove that a token is valid or that the feature is enabled.
An empty MOBILE_SOCIALGPT_ENABLED= entry is an unset emergency override, not a deliberate service shutdown. Explicit false, 0, or off disables SocialGPT even for existing valid tokens; invalid nonempty values fail closed. An active browser session in My Profile means its server-side key is active; it cannot prove that the browser still has the local credential or that global access is enabled.
A server-side SocialGPT policy denial remains HTTP 403 with socialgpt_feature_unavailable. When OpenAI itself reports exhausted API credits or quota, the AI request instead supplies error_code: openai_quota_exhausted, retryable: false, and a localized explanatory user_message (normally HTTP 429). These describe the OpenAI provider billing/project quota, not the user's Tools AI Credits wallet or SocialGPT browser permissions. A normal rate-limit error is not classified as exhausted credits. Existing Chrome clients receive the human-readable user_message without a new request format.
The Facebook outcome-configuration bridge uses the same current scoped SocialGPT bearer resolver as the extension AI endpoints. Current provider_socialgpt tokens and compatible legacy SocialGPT tokens are therefore authorized by scope instead of by the old provider name alone.
The Android Tools client can request its dedicated SocialGPT credential during the normal unversioned POST /api/account/login request by adding the optional boolean field sync_socialgpt_token=true.
A successful response keeps the normal account-session fields and adds a separate socialgpt_token object containing access_token, token_type, scope, provider, created, and rotated. Android persists socialgpt_token.access_token for Social Media Tools. The top-level account-session JWT is a different credential and must not be substituted for the scoped SocialGPT credential.
The login-sync flow uses a dedicated owner-bound Android SocialGPT credential. Browser-pairing credentials and other manually created SocialGPT credentials are separate and are never selected for Android login sync. A healthy dedicated Android credential is reused without rewriting it. A missing credential is created, while an inactive, empty, globally scoped, incorrectly scoped, or otherwise unhealthy dedicated Android credential is rotated and narrowed back to the single ai.socialgpt scope.
If account authentication succeeds but the requested SocialGPT synchronization cannot be completed and auditable, Tools returns HTTP 503 with error_code: socialgpt_token_sync_failed. No partial SocialGPT credential is returned.
POST /api/ai/socialgpt/respondSocialGPT-style reply/verify/modify endpoint.
Use this for extension/client contracts that depend on SocialGPT fields and behavior.
Direct context input on this endpoint remains limited to 60,000 characters. Clients that need to prepare larger context should use a prefetch session and send prefetch_session_id with the final request.
A successful SocialGPT text response must contain visible response text. If an otherwise successful reasoning-model response consumes its output budget without producing visible text, Tools performs one bounded retry with lower reasoning effort and a larger output allowance. If that retry still produces no visible answer, Tools returns HTTP 502 with error_code: empty_visible_response instead of returning ok: true with an empty response.
Verification requests preserve the configured reasoning policy and use larger provider-safe ceilings because Responses reasoning counts inside the output-token budget. The resilient verify pass reserves 16,000 output tokens, the mandatory web-search lookup reserves at least 8,000, and the final verified rewrite reserves 8,000. If OpenAI still returns incomplete with max_output_tokens, SocialGPT performs one bounded recovery attempt with a larger allowance, up to 32,768 output tokens. These values are ceilings, not target usage.
The response includes additive diagnostics when available: timing with per-stage milliseconds, response_excerpt, backend, and recovery metadata. Existing clients can ignore these fields.
Clients that want live progress may send a stable per-request client_request_id (maximum 80 characters, using only letters, digits, ., _, : and -) and poll GET /api/ai/socialgpt/status/{clientRequestId} with the same SocialGPT bearer credential. Progress stages are safe, short-lived telemetry such as accepted, initial_analysis, web_search, finalizing, complete, and their completion counterparts. During a verification requiring web lookup, progress.meta.preliminary_response may contain up to 12,000 characters of the first security-screened AI answer, visible as an unverified draft while source checking continues. The field is optional, only available to the authenticated owner of the request, expires after 10 minutes, is carried across nonterminal progress stages and disappears at complete. It must never be treated as source-verified, cached in public storage, posted as a finished answer or included in diagnostics. The final POST /respond result is authoritative and replaces the draft. Older clients that do not send client_request_id keep the existing synchronous request behavior unchanged.
POST /api/ai/prefetch-sessions/openOpens or reuses a SocialGPT prefetch session. A context fragment may be supplied immediately or added later.
Each prefetch context upload is limited to 500,000 characters. A complete prefetch session may contain up to 1,000,000 context characters.
If the prefetch store cannot persist the session, Tools returns HTTP 503 with the sanitized payload:
{
"ok": false,
"error": "Could not persist the requested prefetch session."
}
Clients should treat this as a temporary service/storage failure rather than a validation failure and must not assume that the session was created or renewed.
POST /api/ai/prefetch-sessions/{sessionId}/contextAdds or replaces context in an existing prefetch session. Use fragment_key to keep independent context fragments, or send replace=false to append to an existing fragment.
Accumulated fragment content is preserved when more context is appended. The response includes context_char_count, max_fragment_input_char_count, and max_context_char_count so clients can track the current session budget.
If the updated session cannot be persisted, this endpoint returns the same HTTP 503 payload shown for the open endpoint. The client must not treat that response as a successful append.
DELETE /api/ai/prefetch-sessions/{sessionId}Closes a prefetch session when the client no longer needs it.
Close is idempotent. Closing a session that was already closed, expired, does not exist, or is not owned by the authenticated user still returns HTTP 200 because the caller's desired end state is already satisfied. Tools does not disclose whether a non-owned session exists and never deletes another user's session.
A close that removes a live owned session returns closed=true, already_closed=false, and the final safe session summary. An already-absent/non-owned close returns the same non-disclosing success shape:
{
"ok": true,
"closed": false,
"already_closed": true,
"session": null
}
A real prefetch-store access failure still returns HTTP 503 with a sanitized error response; backend/cache details are not exposed to the client.
GET /api/social-media-tools/extension/validate-tokenValidates token shape/scope for extension flows.
GET /api/ai/socialgpt/entitlementA no-cost check of the current authenticated caller's SocialGPT feature policy, used after token validation when checking a browser connection. Returns ok: true with features.socialgpt as true or false; it does not call OpenAI or determine OpenAI billing balance. A missing, revoked or unlinked bearer follows the existing SocialGPT authentication errors. A policy denial is a valid authenticated response with features.socialgpt: false, not a request to delete or rotate the user's browser credential. A browser that lost local key material must initiate a new approved device pairing; Tools cannot reveal its old token. Re-pairing retires the preceding credential only for the same account and browser instance, with an auditable session_replaced action.
GET /api/social-media-tools/extension/testPOST /api/social-media-tools/extension/testExtension smoke-test endpoints.
GET /api/social-media-tools/extension/models (legacy alias)Backward-compatible alias for GET /api/ai/models.
For new clients, use /api/ai/models.
GET /api/social-media-tools/facebook/outcome-configReturns the Facebook admin outcome-detection configuration for an authenticated SocialGPT client. Authentication uses the ai.socialgpt scope and the same current bearer-token resolver as other SocialGPT extension endpoints.
/api/ai/internal/respond and read /docs/en/ai/openai.