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. To avoid regenerating on every page load, persist the key withtoJSON and restore it with 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.
- If an embed key is compromised, generate a new one. The old key keeps working until it’s explicitly revoked from the dashboard.
- Store embed keys in
localStorage, a secure cookie, or an equivalent client-side persistence mechanism. Regenerate them if the storage is cleared.

