Configure AI providers for embedding generation and completion. Use SHOW AI PROVIDERS to see all available providers and their current status.
Sets the API key for an AI provider. Optionally activates it as the current provider.
| Syntax | ai.setapikey(<provider>, <apiKey> [, <activate>]) | ||
| Arguments | Name | Type | Description |
<provider> | STRING | Provider name (see Supported Providers) | |
<apiKey> | STRING | The API key | |
<activate> | BOOL | Optional. Whether to set this as the active provider (default: true) | |
| Return Type | BOOL | ||
By default, calling ai.setapikey() both sets the key and activates the provider:
GQLRETURN ai.setapikey("openai", "sk-...")
Each provider stores one API key. Calling ai.setapikey() again for the same provider overwrites the previous key. To set keys for multiple providers without activating them, pass false as the third argument, then use ai.setprovider() to switch:
GQLRETURN ai.setapikey("gemini", "AQ.za...", false)
Sets the active embedding provider. The provider's API key must have been set first via ai.setapikey().
| Syntax | ai.setprovider(<provider>) | ||
| Arguments | Name | Type | Description |
<provider> | STRING | Embedding provider name (see Supported Providers) | |
| Return Type | BOOL | ||
GQLRETURN ai.setprovider("openai")
Returns the name of the current embedding provider.
| Syntax | ai.provider() | ||
| Arguments | None | ||
| Return Type | STRING | ||
GQLRETURN ai.provider()
Returns the embedding dimension of the current provider. Returns null if no embedding provider is active or the provider doesn't support embedding.
| Syntax | ai.embeddim() | ||
| Arguments | None | ||
| Return Type | INT | ||
GQLRETURN ai.embeddim()
Sets the active completion provider. The provider's API key must have been set first via ai.setapikey().
| Syntax | ai.setCompletionProvider(<provider>) | ||
| Arguments | Name | Type | Description |
<provider> | STRING | Provider name (see Supported Providers) | |
| Return Type | BOOL | ||
GQLRETURN ai.setCompletionProvider("anthropic")
Returns the name of the current completion provider.
| Syntax | ai.completionProvider() | ||
| Arguments | None | ||
| Return Type | STRING | ||
GQLRETURN ai.completionProvider()