documentation/guides/agent/getting-started.md
Agent adds an AI chat interface to your API reference. Users can ask questions about your API and receive contextual answers based on your OpenAPI document.
<scalar-button title="Chat with Agent" href="https://agent.scalar.com" icon="phosphor/regular/chat-circle-dots"> </scalar-button>
Ready to upgrade? Read more about the pricing.
Agent is enabled by default on http://localhost with 10 free messages. No configuration required.
Scalar.createApiReference('#app', {
url: '/openapi.json',
})
The chat icon appears in the top left corner.
Agent requires a key for production. Without a key, the button and chat interface does not appear.
Scalar.createApiReference('#app', {
sources: [
{
url: 'https://registry.scalar.com/@your-namespace/apis/your-api/latest?format=json',
agent: {
key: 'your-agent-scalar-key',
},
},
],
})
To disable Agent entirely (including on localhost):
Scalar.createApiReference('#app', {
agent: {
disabled: true,
},
})
When you preload specific APIs (e.g. via sources or registry documents), you can hide the control that lets users add more APIs from the public list. Set hideAddApi: true in the agent config for that source:
Scalar.createApiReference('#app', {
sources: [
{
url: 'https://registry.scalar.com/@your-namespace/apis/your-api/latest?format=json',
agent: {
key: 'your-agent-scalar-key',
hideAddApi: true,
},
},
],
})
Only your preloaded APIs are shown; the “+ API” button and “Add context from dozens of API’s” section are hidden.
The agent configuration accepts:
| Property | Type | Default | Description |
|---|---|---|---|
key | string | undefined | Your Agent key |
disabled | boolean | false | Enable or disable Agent |
hideAddApi | boolean | false | Hide the control to add more APIs; only preloaded/registry APIs are shown |
When using multiple sources, configure Agent per source:
Scalar.createApiReference('#app', {
sources: [
{
url: 'https://registry.scalar.com/@your-namespace/apis/first-api/latest?format=json',
agent: {
key: 'key-for-first-api',
},
},
{
url: 'https://registry.scalar.com/@your-namespace/apis/second-api/latest?format=json',
agent: {
key: 'key-for-second-api',
},
},
],
})
Disable globally across all sources:
Scalar.createApiReference('#app', {
agent: {
disabled: true,
},
sources: [
{ url: '/api/v1/openapi.json' },
{ url: '/api/v2/openapi.json' },
],
})