Skip to content

Add Chat to Your App

General Augment is the agent backend for your app. Your product keeps the user interface, auth, billing, and source of truth. General Augment runs the managed agent turn with memory, tools, identity resolution, usage tracking, and observability.

Integration shapeOne backend call per user message.

Your UI talks to your own app backend. Your backend attaches the signed-in user id, calls General Augment, then returns assistant text to the client.

Your chat UIYour app backendGeneral AugmentManaged agent runtime

Use one stable user value per signed-in app user. That lets General Augment attach memory, tool approvals, usage, and future channel identity links to the same person.

Use model: "simple", "balanced", or "complex" as a tier selector instead of hardcoding provider model names. Operators can update the provider model behind each project tier without app code changes. If you prefer OpenAI-style effort hints, use current Responses reasoning.effort: low maps to simple, medium to balanced, and high or xhigh to complex. The legacy top-level reasoning_effort alias remains accepted for existing clients.

  1. Create or open a project in the General Augment dashboard.

  2. Generate a project-scoped API key and store it as GENERAL_AUGMENT_PROJECT_API_KEY.

  3. Add a backend route in your app that accepts a user message and calls /v1/responses.

  4. Pass your signed-in app user id as user.

  5. Render the returned output_text in your existing chat UI.

Expose a small route in your own app. The browser or mobile client should only know about your route, not the General Augment project-scoped key.

Client to backendmessage

The latest user message.

Backend to General AugmentuserId

Use your signed-in app user id.

Backend to General Augmentmetadata.source

Set a stable source such as app-chat, support-chat, or mobile-chat.

General Augment to backendresponse.id

Store in logs for debugging, audit, and support.

Backend to clientoutput_text

Render this in your chat UI.

During app backend tests, set GENAUG_API_BASE_URL=http://127.0.0.1:8787 and point this same client path at the local mock server. The mock returns deterministic Responses and memory fixtures without live model calls or provider credentials.

If your app already owns user OAuth for actions such as Gmail or Calendar, keep those side effects in your backend. Ask General Augment for a summary, draft, or structured action proposal, show your own confirmation UI, then execute with app-held credentials. Delegate tools later only after General Augment credentials, identity links, allowlists, and approval UX are connected.

type ChatInput = {
userId: string;
message: string;
};
export async function generalAugmentChat({ userId, message }: ChatInput) {
const baseUrl = process.env.GENAUG_API_BASE_URL ?? "https://api.generalaugment.com";
const response = await fetch(`${baseUrl}/v1/responses`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.GENERAL_AUGMENT_PROJECT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "balanced",
user: userId,
input: message,
metadata: {
source: "app-chat",
},
stream: false,
}),
});
if (!response.ok) {
if (response.status === 429) {
const retryAfter = response.headers.get("Retry-After");
throw new Error(`General Augment rate limited this user; retry after ${retryAfter ?? "the reset window"}.`);
}
if (response.status === 402) {
throw new Error("General Augment budget or usage limit reached for this project.");
}
throw new Error(await response.text());
}
const payload = await response.json();
return extractOutputText(payload);
}
function extractOutputText(payload: any): string {
return (
payload.output
?.flatMap((item: any) => item.content ?? [])
?.find((part: any) => part.type === "output_text")
?.text ?? ""
);
}

user

A stable app user id, such as your database user id. Avoid email addresses when a durable opaque id is available.

input

The latest user message, or a typed Responses-style input array when you need richer conversation context.

metadata

App-specific routing and diagnostics, such as source, workspace_id, plan, or environment.

previous_response_id

Optional continuity when your app wants to resume from a specific stored response.

Use the same opaque app user id for explicit memory APIs:

await fetch(`${baseUrl}/api/v1/agent/memory/store`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.GENERAL_AUGMENT_PROJECT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: "app-user-123",
fact: "User prefers weekly summaries on Mondays",
fact_type: "preference",
source: "settings",
}),
});

That value is the join key between /v1/responses, durable memory, approvals, traces, and future channel identity links. Regression coverage verifies memory context is scoped per external app user before model dispatch; launch validation should still include explicit memory store/search/profile checks.

General Augment returns a Responses-compatible object. For a normal text reply, read the first output_text part from the output list.

{
"id": "resp_abc123",
"object": "response",
"status": "completed",
"output": [
{
"type": "message",
"content": [
{
"type": "output_text",
"text": "Here is the plan..."
}
]
}
]
}

For debugging and reconciliation, store response id, metadata.general_augment_trace_id, top-level model, metadata.general_augment_model, usage.input_tokens, usage.output_tokens, usage.total_tokens, and metadata.general_augment_cost_usd when present.

SecretsStore GENERAL_AUGMENT_PROJECT_API_KEY in your backend secret manager.
IdentityPass a stable user id for every signed-in user.
LimitsAdd your own app rate limits before forwarding requests.
ToolsKeep tool credentials in General Augment credentials, not prompts.
MetadataSend useful metadata.source values for analytics and debugging.
LogsLog the returned response id in your app request logs.
VerificationRun genaug smoke, genaug verify, and genaug onboarding verify --json before launch.
BackoffHandle 402 and 429 without tight retry loops.