Build an Agent
Creating a Custom Agent
End-to-end tutorial to configure an agent persona, ingest workspace knowledge, and start chat sessions.
Build an index-grounded agent by creating a workspace, attaching domain knowledge, and running completions.
1. Create a Workspace
A workspace serves as your agent's knowledge boundary:
curl -sS -X POST "https://edge.omnistatic.com/v1/workspaces" \
-H "Authorization: Bearer $OMNI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Legal Research Agent"
}'Response:
{
"id": "ws_01jze9m2legal",
"name": "Legal Research Agent",
"createdAt": "2026-08-16T00:00:00.000Z"
}2. Ingest Knowledge Documents
Upload relevant markdown or structured notes into the workspace:
curl -sS -X POST "https://edge.omnistatic.com/v1/workspaces/ws_01jze9m2legal/documents" \
-H "Authorization: Bearer $OMNI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Standard NDA Guidelines",
"markdown": "# Standard NDA Guidelines\n\n1. Mutual confidentiality period is 3 years.\n2. Exclusions: publicly known information and court orders.\n3. Governing law: Delaware.",
"document_payload": { "format": "omni.om", "type": "document" }
}'3. Store Persistent Agent Memories
Save core operational facts:
curl -sS -X POST "https://edge.omnistatic.com/v1/memories" \
-H "Authorization: Bearer $OMNI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Always highlight non-standard indemnity clauses in red or bold text."
}'4. Query Your Agent with Scoped Context
Pass the X-Omni-Workspace header to ground completions in your workspace's knowledge and memories:
curl -sS -X POST "https://edge.omnistatic.com/v1/chat/completions" \
-H "Authorization: Bearer $OMNI_API_KEY" \
-H "X-Omni-Workspace: ws_01jze9m2legal" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "What is our standard mutual confidentiality term?" }
]
}'The agent automatically retrieves the NDA document from the workspace and answers:
"According to our Standard NDA Guidelines, the mutual confidentiality period is 3 years."