The SDK supports two authentication methods. Each one is designed for a specific environment.Documentation Index
Fetch the complete documentation index at: https://relevanceai.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
API keys vs. embed keys
API keys
Grant full access to a project. Use in server-side applications, background workers, and other secure environments where the key is never exposed to end users.
Embed keys
Scoped to a single public agent or workforce. Use in browser applications and other client-side contexts where the key is visible in network traffic.
Regions
Every Relevance AI project is deployed to a specific region. Match the region where your project was created — check the project settings in the dashboard.| Constant | Region |
|---|---|
REGION_US | United States |
REGION_EU | Europe |
REGION_AU | Australia |
API key authentication
API keys are available in the project settings on the dashboard. They follow thesk-... format and grant unrestricted access to every resource in the project.
The fastest way to authenticate is with createClient:
Key instance explicitly and pass it to the Client constructor:
createClient vs. direct construction, see Client.
Embed key authentication
Embed keys are generated at runtime and scoped to a single public agent or a single workforce. They’re safe to use in browser environments because they can’t access resources outside their scope.For an agent
For a workforce
Persisting embed keys
Generating an embed key involves a network request and, importantly, initializes a specific user session. You should persist keys to avoid unnecessary latency and to ensure session continuity; regenerating a new key on every page load will prevent the user from restoring their past conversations. To maintain the session, persist the key withtoJSON() and restore it using the Key constructor.
Save to localStorage
Restore from localStorage
toJSON returns a plain object containing every field needed to reconstruct the key — region, project, scoped agent or workforce ID, and the task prefix used for conversation namespacing.
Security guidance
- Embed keys are the only safe authentication method for browser environments. They’re scoped to a single agent or workforce and can’t access other project resources.
- Immediately revoke any compromised API keys before regenerating. Existing keys do not auto-expire and must be manually decommissioned via the dashboard to terminate access.
- Store embed keys in
localStorage, a secure cookie, or an equivalent client-side persistence mechanism. Regenerate them if the storage is cleared.

