windmill-labs/windmill · error
Anthropic not initialized
Error message
Anthropic not initialized
What it means
Same guard as the OpenAI variant but for the Anthropic SDK client cached on WorkspacedAIClients. getAnthropicClient() throws 'Anthropic not initialized' when anthropicClient is undefined — createAnthropicClient(workspace) (which builds a client against the AI proxy base URL) has not run for the current workspace.
Source
Thrown at frontend/src/lib/components/copilot/lib.ts:557
createOpenaiClient(workspace: string): OpenAI {
return createOpenAIProxyClient(getAiProxyBaseURL(workspace))
}
createAnthropicClient(workspace: string): Anthropic {
return createAnthropicProxyClient(getAiProxyBaseURL(workspace))
}
getOpenaiClient() {
if (!this.openaiClient) {
throw new Error('OpenAI not initialized')
}
return this.openaiClient
}
getAnthropicClient() {
if (!this.anthropicClient) {
throw new Error('Anthropic not initialized')
}
return this.anthropicClient
}
}
export const workspaceAIClients = new WorkspacedAIClients()
export async function testKey({
apiKey,
workspace,
resourcePath,
model,
abortController,
messages,
aiProvider
}: {
apiKey?: string
workspace?: stringView on GitHub (pinned to e474e8803c)
Solutions
- Call workspaceAIClients.createAnthropicClient(workspace) before using getAnthropicClient().
- Verify the workspace argument matches the active workspace; re-create on workspace switch.
- Route through AIChatManager's clients.anthropic so initialization is handled centrally.
- If only OpenAI models are intended, ensure the selected model does not route to the Anthropic client.
Example fix
// before const anthropic = workspaceAIClients.getAnthropicClient() // after workspaceAIClients.createAnthropicClient(workspace) const anthropic = workspaceAIClients.getAnthropicClient()
Defensive patterns
Strategy: validation
Validate before calling
function needsAnthropic(model: string): boolean {
return /claude/i.test(model)
} Try / catch
try {
const anthropic = workspaceAIClients.getAnthropicClient()
// use anthropic
} catch (e) {
if (e.message === 'Anthropic not initialized') {
workspaceAIClients.createAnthropicClient(workspace)
} else throw e
} Prevention
- Initialize both OpenAI and Anthropic clients together at workspace setup.
- Gate Anthropic-only code paths on model selection (Claude models) and initialize lazily there.
- Re-run initialization after HMR or workspace changes in dev.
When it happens
Trigger: Calling workspaceAIClients.getAnthropicClient() before createAnthropicClient(workspace) was called for the active workspace; accessing Anthropic-only features (Claude models, Anthropic-Messages-API completions) on a path that only initialized the OpenAI client.
Common situations: Selecting a Claude model in a flow that only ran OpenAI setup; workspace switch without re-init; fresh module instance in tests or after HMR missing the initialization call.
Related errors
- OpenAI not initialized
- Failed to start test run - testFlow returned undefined
- No flow available to test step from. Please ensure you have
- Module '${moduleId}' not found. This module either doesn't e
- Fixing frontend code is not supported
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/c0b015b771d9c1af.
Report an issue: GitHub.