GalaxyX · Developer documentation
REST API reference
Integrate with the GalaxyX API to send agent requests, generate and edit images, manage personal profile memory, and manage your own API keys. Expand an endpoint to see its authentication, input, and response.
Base URL & authentication
GalaxyX API: https://api.galaxyx.net
Authorization: Bearer <YOUR_GALAXYX_API_KEY>
Content-Type: application/jsonExternal clients should use a gx_ API key in the Authorization header. Send only the key value after Bearer, without a variable name or an equals sign. GalaxyX also accepts Firebase ID tokens as Bearer credentials. The website uses the HttpOnly __session cookie with credentials: 'include' and an allowed first-party Origin. A localhost cookie cannot authenticate requests to the production API host.
Sign in with a registered, email-verified account, then open Settings to create, list, narrow, or revoke your API keys. The /v1/keys endpoints also accept a Firebase ID token or a session cookie with an allowed Origin. API keys receive 403 on key management endpoints.
Use chat for agent requests, images for Image Studio, and profile for display-name updates. Missing scope returns HTTP 403 with API_KEY_SCOPE_REQUIRED. Before narrowing a legacy key or replacing it with a scoped key, migrate any chat attachment downloads to Firebase account authentication. To replace a key while keeping both credentials active during verification, issue the new key in a free slot and switch your client before revoking the old key.
Keep keys on your server, out of browser bundles, URLs, and logs. Save the full key when issued: it cannot be retrieved later. Limits: 5 active keys per account and 10 successful creations per one-hour window; revoking a key does not reset the creation count.
Web and API share the same paid balance. Fixed-price actions use the displayed credit cost. Trial credits are charged at 2.0× provider cost and work with eligible Web features.
GalaxyX API endpoints
GET /health
Public
Liveness check. Returns 200 with { "status": "ok" }.
GET /
Public
Returns a plain-text service greeting. Use /health for a JSON liveness check.
GET /v1/agent/models
Firebase account or API key with chat scope
Returns { models: [{ id, name, provider }], defaultModel } for the available chat models.
POST /v1/agent/:chatId
Firebase account or API key with chat scope
Send a JSON chat request and receive a text/event-stream response. Image Studio generation from chat also requires images scope. See the request and streaming reference below.
GET /v1/chat-attachments/:owner
Firebase account or session cookie
Fetch a private chat attachment from the returned attachment URL. The account must own the attachment or have received it through a guest transfer. Apps using a legacy API key for attachment downloads must switch to Firebase account authentication before the legacy restriction is enabled.
GET /v1/user/memory
Firebase account or session cookie; guests allowed
Read your personal profile memory as { revision, entries }. No model call or credit charge. See the memory reference below.
PATCH /v1/user/memory
Firebase account or session cookie; guests allowed
Edit or clear your personal profile memory using JSON { revision, update }. Returns 204 without a body; a stale revision returns 409 MEMORY_CONFLICT.
PATCH /v1/user/change_name
Registered Firebase account or API key with profile scope
JSON { "name": "New name" }. Updates your user profile and returns { "success": true }.
POST /v1/keys
Verified, registered Firebase account
Send { "name": "My application", "scopes": ["chat"] }. The name must be 1–50 characters after trimming. If omitted, scopes default to ["chat", "images"]. A 201 response includes { id, name, key, scopes }. The full key is returned only once.
GET /v1/keys
Verified, registered Firebase account
Returns { keys: [{ id, name, prefix, scopes, createdAt }] } for your active keys. A legacy key without explicitly assigned scopes has scopes: null. Full keys cannot be retrieved.
PATCH /v1/keys/:id/scopes
Verified, registered Firebase account
Send a nonempty set of scopes such as { "scopes": ["chat"] }. A 204 response means the new permissions apply from the next authentication. Expanding explicit scopes requires issuing a new key.
DELETE /v1/keys/:id
Verified, registered Firebase account
Revokes your key. Returns 204 without a body, or 404 if the key does not exist or belongs to another user.
All paths above are relative to https://api.galaxyx.net. Versioned endpoints use /v1, without an /api prefix. API keys act on the account that created them; key management is limited to that account’s own keys.
Send a chat request
Choose a chat ID of 1–128 letters, digits, underscores, or hyphens. Reuse it to continue a conversation and supply the conversation context in recent_messages; the chat ID alone does not load prior messages into the request. Set new_chat to true when creating a room. Requests use JSON, including base64 file contents.
curl --no-buffer https://api.galaxyx.net/v1/agent/demo-chat \
-H "Authorization: Bearer $GALAXYX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
--data '{
"message": { "text": "Help me plan a trip to Tokyo." },
"new_chat": true,
"language": "en",
"recent_messages": [],
"attachments": [],
"config": { "temperature": 0.2, "maxOutputTokens": 8192 }
}'| Field | Contract |
|---|---|
| message | Required object: { text: string }; text is at most 20,000 characters. |
| new_chat | Boolean; default false. |
| recent_messages | At most 20 entries; default []. Each entry: { id, role: "user" | "model", text, attachments? }. id ≤100 characters; text ≤20,000. Attachment metadata objects: { type: "image" | "file" | "url", url, file_name } (url ≤1,000; file_name ≤100 characters). |
| language | Optional: "en" or "jp". |
| model | Optional chat model ID from GET /v1/agent/models. Omit to use its defaultModel (currently gemini-3.8-flash). Image tiers use a separate catalog at /v1/images/models. |
| attachments | Up to eight attachments, including up to four non-images; default []. Each entry: { name?, mimeType, data }. data is raw base64 (no data URL prefix), with a 14,000,000 character limit per non-image attachment. name ≤200 characters (default "file"); MIME types start with image/, application/, text/, audio/, or video/. Hosting and provider limits still apply. |
| config | Optional object: temperature 0–2 (default 0.2), topP 0–1, topK integer 1–100, maxOutputTokens integer 1–8192 (default 8192), seed integer. All fields optional. Unknown config and top-level keys are rejected. |
Personal profile memory
GET and PATCH /v1/user/memory read and edit the personal preferences, goals, constraints, and facts shared across your chats. Both act only on the authenticated account; do not send a UID. Authenticated guests are allowed, and email verification is not required. These endpoints make no model calls and consume no credits.
Use Authorization: Bearer with a Firebase ID token. GalaxyX API keys do not grant access to saved personal memory. Session cookies (__session) are also accepted; browser requests need credentials: 'include'. If an Origin header is present with cookie authentication, it must be an allowed first-party Origin. The public API path has no /api prefix; the website’s /api/v1/user/memory path is a separate Next.js session proxy.
Read the current profile
curl https://api.galaxyx.net/v1/user/memory \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN"
// Example response (200)
{
"revision": 3,
"entries": [{
"key": "response_language",
"category": "preference",
"value": "English",
"updated_at": "2026-11-07T00:00:00.000Z",
"source_chat_id": "settings"
}]
}GET returns a nonnegative integer revision and up to 40 entries. Each entry contains key, category, value, updated_at (an ISO timestamp), and source_chat_id (the originating chat ID, or settings for direct API edits). An account without a saved profile returns { "revision": 0, "entries": [] }. Memory route responses use Cache-Control: no-store.
Add or change entries
// Use the revision from your latest GET; 3 is only an example.
curl -i -X PATCH https://api.galaxyx.net/v1/user/memory \
-H "Authorization: Bearer $FIREBASE_ID_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"revision": 3,
"update": {
"upsert": [{ "key": "response_language", "category": "preference", "value": "Japanese" }],
"remove": [],
"clear": false
}
}'
// Success: HTTP 204, no response body. GET again to read the updated profile.revision: required nonnegative integer matching the current profile revision.update: required object containing all three fields: upsert, remove, and clear. Unknown fields are rejected at every object level.upsert: at most 10 objects containing only key, category, and value. An existing key is replaced; a new key is added.key: 1–64 characters matching^[a-z][a-z0-9_]{0,63}$. Category must be preference, goal, constraint, or fact. Values are trimmed and must contain 1–240 characters.remove: at most 40 keys using the same key format. A key cannot appear in both remove and upsert; duplicate upsert keys are rejected.clear: required boolean. When true, both arrays must be empty. A profile holds at most 40 entries; exceeding capacity fails without automatically evicting entries.
Remove an entry or clear the profile
// PATCH bodies: first GET the current revision before each request.
// Remove one entry (example revision 4):
{ "revision": 4, "update": { "upsert": [], "remove": ["response_language"], "clear": false } }
// Clear all personal profile entries (example revision 5):
{ "revision": 5, "update": { "upsert": [], "remove": [], "clear": true } }Each successful PATCH increments revision, including a clear or an edit that leaves entries unchanged. Clearing keeps the revision rather than resetting it to zero. Removing entries or clearing this profile does not delete chat history or project memory.
Memory errors & conflicts
Memory errors use { "error": { "code": "MEMORY_CONFLICT" } }. Standard authentication errors also apply: missing or invalid credentials return 401; a forbidden cookie Origin or disabled API-key access returns 403.
- 400 INVALID_MEMORY_UPDATE: malformed JSON, missing fields, invalid values, unknown fields, or conflicting patch operations.
- 409 MEMORY_CONFLICT: another request changed the profile. GET it again, review your intended edits against the latest entries, and PATCH with the new revision. Do not blindly retry the stale body.
- 503 MEMORY_READ_FAILED or MEMORY_SAVE_FAILED: reading or saving failed. Exceeding the 40-entry profile capacity also returns MEMORY_SAVE_FAILED. After an uncertain write, GET the profile before deciding whether to retry.
Image generation & editing
Use the GalaxyX Image Studio at /image or integrate through the endpoints below. All image endpoints require a registered account or its API key; guest accounts are rejected. Generation requires at least 0.01 credits and no active usage restriction. Cookie-authenticated writes also require an allowed first-party Origin.
GET /v1/images/models
Registered account or API key with images scope
Returns { models: [{ tier, model, provider, available }] }. Check availability before selecting a tier. Provider access and quota are checked separately.
POST /v1/images/uploads
Registered account or API key with images scope
Upload raw PNG, JPEG, WebP, or HEIC bytes with the matching Content-Type (not multipart or base64). Returns 201 with { id, url, mimeType }. Upload each reference separately.
POST /v1/images/generate
Registered account or API key with images scope and credits
Generate or edit an image using JSON. Waits for completion and returns a saved run with outputs and references as JSON, rather than an SSE stream. See the fields and examples below.
GET /v1/images/assets/:id
Registered account or API key with images scope
Streams the owned image. Use ?download=1 for an attachment response.
GET /v1/images/history
Registered account or API key with images scope
Returns { items, nextCursor } with up to 10 sessions, newest updated first. Pass ?before=<session UUID> using nextCursor for the next page; null means the end.
GET /v1/images/sessions/:id
Registered account or API key with images scope
Returns the latest run for your session, including reference and output assets with stable authenticated paths. id must be a session UUID.
GET /v1/images/sessions/:id/versions
Registered account or API key with images scope
Returns { items, nextCursor } with up to 10 version summaries, newest created first. Pass ?before=<run UUID> using nextCursor for more versions.
GET /v1/images/runs/:id
Registered account or API key with images scope
Returns one saved run, including its status, request fields, references, and outputs. id is the requestId UUID used to create that run.
| Tier | Model | Output settings |
|---|---|---|
| performance | gpt-image-2.5-sunburst | High quality; available when configured. |
| balanced | gemini-nano-banana-2.1 | 1K output. |
| low-cost | gemini-3.1-flash-lite-image | 1K output. |
Fetch /v1/images/models for current availability. The API does not automatically switch tiers or providers when the selected one is unavailable.
Generate an image
curl https://api.galaxyx.net/v1/images/generate \
-H "Authorization: Bearer $GALAXYX_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"requestId": "72b9c8ec-49cb-45cb-8d06-743410e1ca5b",
"mode": "generate",
"tier": "balanced",
"prompt": "An aircraft flying above the clouds at sunset",
"ratio": "16:9",
"referenceIds": []
}'requestId: required UUID. Create a fresh UUID for each new generation or edit.sessionId: optional UUID of an existing creation. Include it to add a version; omit it to start a new session.mode: required, eithergenerateoredit.tier: required,performance,balanced, orlow-cost. Select a tier rather than sending a model ID.prompt: required, 1–4,000 characters after trimming.ratio: required,1:1,3:2,2:3, or16:9.referenceIds: array of asset UUIDs, default []. Generate mode requires no references; edit mode requires one or more images owned by your account.
Upload references and edit
curl https://api.galaxyx.net/v1/images/uploads \
-H "Authorization: Bearer $GALAXYX_API_KEY" \
-H "Content-Type: image/png" \
--data-binary @reference.png
// Upload response (201); URL is temporary
{ "id": "109bbdd7-75ba-4bab-9c49-73a8c779777e", "url": "/v1/images/assets/109bbdd7-75ba-4bab-9c49-73a8c779777e", "mimeType": "image/webp" }
// POST /v1/images/generate with Content-Type: application/json
{
"requestId": "78762524-85a0-4fc6-9aaa-4e06b76552c0",
"mode": "edit",
"tier": "balanced",
"prompt": "Change the sky in Image 1 to a sunset",
"ratio": "16:9",
"referenceIds": ["109bbdd7-75ba-4bab-9c49-73a8c779777e"]
}Upload each reference in its own request. References are numbered Image 1, Image 2, and so on in referenceIds order. Uploads are oriented, resized to fit within 2048 pixels, and converted to WebP; large results may be reduced further. The original file is not preserved verbatim. To edit a generated result, reuse its output asset id in referenceIds and include its sessionId to keep the new version in the same creation.
Results, history & retries
A successful generation returns HTTP 200 with the run fields: id (equal to requestId), sessionId, mode, tier, model, prompt, ratio, referenceIds, createdAt (Unix milliseconds), status, outputIds, outputs, and references. Each output or reference contains { id, url, mimeType }. Saved runs have status pending, completed, or failed; a failed run includes an error code.
Keep the original request body and requestId when retrying an uncertain request. Replaying a completed or failed run returns the saved result without another generation or credit debit; a pending run returns 409 IMAGE_IN_PROGRESS. Use GET /v1/images/runs/:id to check it. A new attempt after a failure needs a new requestId. Only one run can be active in a session at a time.
Sessions, versions, and assets belong to your account. Resolve asset paths against the API origin and send your session or Bearer credential on each request. Add ?download=1 to download an original. Image API responses disable caching. A disconnected client does not cancel generation; reopening an interrupted pending run after six minutes marks it failed with IMAGE_INTERRUPTED and unlocks the session.
Completed runs consume credits based on reported usage. Completion and credit debit are applied once per requestId. Failed calls do not debit your GalaxyX credits. The account is checked before processing and an active generation prevents other billable chat or image requests from starting for that account.
Image errors
Errors use { error: { code } }. Standard authentication errors also apply. A saved failed run can be returned with HTTP 200 on replay, so always inspect status as well.
- 400: INVALID_IMAGE_REQUEST, INVALID_SESSION, or INVALID_CURSOR.
- 402 INSUFFICIENT_CREDITS; 403 LOGIN_REQUIRED or FORBIDDEN_ORIGIN.
- 404 IMAGE_NOT_FOUND or SESSION_NOT_FOUND.
- 409 IMAGE_IN_PROGRESS: the request or session already has a pending run.
- Empty or undecodable images return INVALID_IMAGE. Hosting or providers may reject requests beyond their own limits.
- 415 INVALID_IMAGE: unsupported Content-Type, format, or undecodable image.
- 502: generation failed, for example IMAGE_PROVIDER_FAILED, OPENAI_AUTH_FAILED, NO_IMAGE_RETURNED, or INVALID_IMAGE_USAGE.
- 503 OPENAI_NOT_CONFIGURED: Performance is unavailable. 500 IMAGE_REQUEST_FAILED: unexpected image request failure.
Streaming responses & errors
Chat returns Server-Sent Events (text/event-stream). Each data field contains JSON; read its status property rather than an SSE event name. Parse complete events separated by a blank line, buffering partial network chunks. Use fetch for POST requests; native EventSource cannot send this JSON body or Bearer header.
data: {"status":"room_created","id":"demo-chat","title":"Trip to Tokyo"}
data: {"status":"progress","text":"Searching on the web..."}
data: {"status":"final_answer","text":"Here is your itinerary...","chat_limit_reached":false}
room_created/room_updated: room ID and title.progress: tool progress text.warning: code and message, for example an attachment save failure.error: code and user-facing message; treat this as a failed generation.final_answer: answer text, chat_limit_reached, and optional function_responses. This is the completed answer; title updates and warnings arrive before it.- Web search results may include
function_responses[].response.sources, an array of objects withurlandtitle.
Check the HTTP status before reading the stream. HTTP 200 alone does not mean generation succeeded: errors can arrive inside the stream. Disconnecting does not currently cancel upstream model work.
// Example validation error (HTTP 400)
{ "error": { "code": "INVALID_REQUEST", "issues": [
{ "path": "model", "message": "Unsupported model" }
] } }- 400: invalid input or a disallowed guest profile update.
- 401: missing or invalid authentication.
- 402 TOKEN_LIMIT_REACHED: insufficient or invalid credit balance, or account usage restriction, before generation.
- 403: forbidden Origin, unverified/guest key management, attempting key management with an API key, or API_ACCESS_DISABLED.
- 404 NOT_FOUND: unavailable key; 409 KEY_LIMIT: active key limit reached.
- 409 CHAT_IN_PROGRESS: another chat is active for this account. 413: body exceeds 20 MiB on routes with a body size limit. 429 KEY_RATE_LIMIT: key creation limit; Retry-After: 3600. 503 UPLOAD_CAPACITY_REACHED: retry shortly.
Error bodies vary by endpoint; user profile routes also return string errors. Model and tool usage consumes credits. Billable chat and image requests reserve credits before provider submission.