Galactre
USD

Choose how catalog prices and estimates appear. Checkout and account records remain in IDR.

Open Chat

GALACTRE / CODE EXAMPLES

Less guesswork.
More working context.

Explore focused examples for the Galactre browser API, from model discovery to conversation cleanup. Read the requirements, copy the function and run it only when your application is ready.

01 / SELECT AN OPERATION

One task at a time.

These are complete function definitions, not background requests. All routes belong to the Galactre origin. Session tokens and private conversation content must stay out of shared code.

These examples use the browser session API. Backend applications can issue model-scoped server keys in API Access and use the separate responses contract.

Review access requirements
GET/api/v1/chat/models

Discover models

Read the current GT model catalog before choosing a family. A public model listing is not a generation permission.

JAVASCRIPT / COPY TO YOUR OWN GALACTRE PAGE
// Run on the Galactre origin. Nothing is fetched until you call the function.
async function listGalactreModels() {
  const response = await fetch('/api/v1/chat/models', { cache: 'no-store' });
  if (!response.ok) throw new Error('Galactre catalog unavailable.');
  const catalog = await response.json();
  if (!catalog.catalog_available || !Array.isArray(catalog.models)) {
    throw new Error('Model availability could not be confirmed.');
  }
  return {
    models: catalog.models.filter(model => model.available === true),
    releases: (catalog.releases || []).filter(model => model.available === true)
  };
}
// A model returned here still requires session, quota and policy checks.

Before you run it

  • Check the HTTP response and catalog_available separately.
  • Use available models permitted for the session. Guest chat supports Lunar.
  • Treat null specifications and rates as unpublished, not unlimited or free.

Expected behavior

Returns the available catalog entries. This function does not create a session or generate text.

Handle failures explicitly

02 / BUILD AROUND THE REQUEST

Make success useful.
Make failure understandable.

The request is one part of the experience. State, rendering, access checks and recovery belong in the application around it.

Keep submission state explicit

Validate the draft, prevent duplicate sends while pending and preserve enough state to inspect failures. A network error alone does not prove execution was cancelled.

Wait when rate limited

Honor Retry-After. Refresh the session allowance after an admitted request, and avoid automatically resubmitting after an uncertain outcome.

Render model text safely

Use textContent or a properly sanitized renderer. Generated text, conversation titles and error messages should never be inserted as trusted HTML.

Separate text from actions

A suggested command, test or deployment is not executed by chat. Enforce authorization, validation and review in your own application before taking action.

04 / BEFORE YOU COPY

Know where
the example belongs.

How do these examples select a model version?

The model field accepts a family ID or an exact release ID. Replace gt-lunar with an available ID from catalog.releases to pin a version. The older family shorthand continues to follow the current default. Inspect the returned model_id; do not infer the resolved version from your request label.

Does selecting or copying an example send a model request?

No. The page only changes the displayed code or copies text. Each function runs only when explicitly called from your application. The examples contain no live credentials.

Can I use these snippets from a different origin or a backend?

These browser snippets require the Galactre origin and session. For a backend, issue an expiring, model-scoped key in API Access and call POST /api/v1/responses with Authorization: Bearer and Idempotency-Key. Keep keys on your server; do not copy browser cookies or expose keys to another website.

Are these official SDK methods?

They are plain JavaScript examples using native fetch, not a separately published SDK package. The Developers page documents the current endpoint contract and limitations.

Can I stream tokens, stop a response or use tools?

These minimal examples request completed JSON. Set stream to true for SSE start, delta and completed events. Use the request ID to check status or request cancellation; a disconnect can leave usage needing reconciliation. Signed-in browser conversations support selected private knowledge, calculator and current-time tools. Server keys do not delegate those private sources. Files and image generation are not released.

What should I do when history cannot be saved?

Treat the completed answer and history persistence independently. A response may report history.state = unavailable. Preserve important non-sensitive results appropriately, and do not assume the exchange will reappear after reload.

May I hardcode a session token into the snippet?

No. Discover current session state and use the returned CSRF token only with that session. Keep cookies, credentials and private conversation content out of public examples, URLs and logs.

TRY THE EXPERIENCE

Start a conversation.
Then build with purpose.