edytlab
API Reference

API Keys and Providers

Store and test provider keys in the OS keychain, and choose the provider, model, address and effort.

On this page20 commands

Called through tauri-bridge.ts. Each returns Promise<T> and throws a string on Rust Err(_).

API Keys

FunctionReturnsDescription
setApiKey(key)KeychainPersistenceStore the API key for the active provider in the OS keychain. Resolves with where it landed, as setApiKeyFor does.
setApiKeyFor(provider, key)KeychainPersistenceStore the API key for a specific provider and make it the active one. Resolves with where the save landed: persistent is false when it fell back to the kernel keyring because no Secret Service could be reached, so it lasts only until restart. The key is saved and used either way. The other setters that write to the keychain answer the same way.
hasApiKey()booleanCheck whether the active provider has a key configured. Rejects when the keychain could not be read (a locked keyring, say), which is not the same as false: a key may be stored and could not be looked up.
hasApiKeyFor(provider)booleanCheck whether a specific provider has a key. For chatgpt there is no key: it is true while the ChatGPT sign-in is signed in. Rejects when the keychain could not be read, as hasApiKey does.
getKeychainPersistence()KeychainPersistenceWhether a key saved now survives a reboot (settings are in a file and always do). persistent is false on Linux with no Secret Service running, where keys are kept in the kernel keyring until restart; reason says why. The setters answer the same shape for the save they just made.
clearApiKeyFor(provider)voidRemove a specific provider's key from the keychain.
clearApiKey()voidRemove the API key for the active provider from the keychain.
testApiKeyFor(provider, key, baseUrl?, model?)ProbeReportProbe a provider at the endpoint and model currently on screen. Reports three outcomes: ready, connected but the model cannot call tools (so editing will fail), or unreachable. For chatgpt the key and address are ignored: it is tested with the signed-in session, on a provider of its own so a turn that is running is not affected, and rejects when not signed in.
testApiKey(key)voidValidate a key with a 1-token probe request. Throws on failure.

Provider and Model

FunctionReturnsDescription
listProviders()ProviderId[]Returns ["anthropic", "openrouter", "openai", "groq", "gemini", "ollama"].
getActiveProvider()ProviderIdReturns the currently active provider ID.
setActiveProvider(provider)KeychainPersistenceSwitch the active provider. Rebuilds the agent. Resolves with where the choice was saved, as setApiKeyFor does. chatgpt can be made active only while the ChatGPT sign-in is signed in.
listModelsFor(provider, apiKey?)ModelCatalogueLive list; Anthropic falls back to a built-in list without a key or when the fetch fails. Cached 10 minutes. Each model carries reasoning_levels, which only chatgpt fills in: the levels the signed-in account lists for it. For chatgpt it is the account's own list, read with its session, and rejects when not signed in.
getActiveModel(provider)stringReturns the model ID selected for the provider.
setActiveModel(provider, model)KeychainPersistenceSet the active model for a provider. Resolves with where the choice was saved, as setApiKeyFor does.
getBaseUrlFor(provider)string | nullThe base URL the provider has been pointed at, or null when it is on its default. Rejects when the keychain could not be read, which is not the same as null, and rejects without reading after a startup the keychain refused.
defaultBaseUrlFor(provider)stringThe URL the provider ships with. Shown as the field's placeholder.
setBaseUrlFor(provider, baseUrl)KeychainPersistencePoint a provider at a proxy, a gateway or a local server. An empty string restores the default. Resolves with where the URL was saved, as setApiKeyFor does; clearing writes nothing and is always persistent.
getEffortFor(provider)ReasoningEffort | nullThe reasoning effort saved for the provider, or null when the model's own default applies. Only Anthropic and the ChatGPT plan have the setting; any other provider answers null. Rejects when the keychain could not be read, as getBaseUrlFor does.
setEffortFor(provider, effort)KeychainPersistenceSet how hard the model works on a response: low, medium, high, xhigh or max, sent as output_config.effort. null restores the model's default. Anthropic and the ChatGPT plan only; any other provider is refused. For chatgpt the level is sent as reasoning.effort, and only when the model's list names it. Rebuilds the agent, and resolves with where the level was saved, as setBaseUrlFor does.