mastra-ai/mastra · error
API not implemented
Error message
API not implemented
What it means
OpenAPIToolset's base implementation of getApiClient throws 'API not implemented'. The toolset can generate tools from its schema without a live client (baseClient defaults to {}), but if you ask for an actual API client, only concrete subclasses that bind a real HTTP client can answer. The error marks the unimplemented capability, not a runtime failure.
Source
Thrown at packages/core/src/integration/openapi-toolset.ts:27
authType: string = 'API_KEY';
constructor() {}
protected get toolSchemas(): any {
return {};
}
protected get toolDocumentations(): Record<string, { comment: string; doc?: string }> {
return {};
}
protected get baseClient(): any {
return {};
}
async getApiClient(): Promise<any> {
throw new Error('API not implemented');
}
protected _generateIntegrationTools<T>() {
const { client: _client, ...clientMethods } = this.baseClient;
const schemas = this.toolSchemas;
const documentations = this.toolDocumentations;
const tools = Object.keys(clientMethods).reduce((acc, key) => {
const comment = documentations[key]?.comment;
// const doc = documentations[key]?.doc;
const fallbackComment = `Execute ${key}`;
const tool = createTool({
id: key,
inputSchema: schemas[key] || z.object({}),
description: comment || fallbackComment,
// documentation: doc || fallbackComment,
execute: async input => {View on GitHub (pinned to 75dd419e61)
Solutions
- Use a concrete toolset subclass that overrides getApiClient and returns the generated client
- If you only need the generated tools, use _generateIntegrationTools output / listTools instead of getApiClient
- Construct the API client from the OpenAPI document yourself using the spec you loaded
- Extend OpenAPIToolset and override getApiClient to return your bound client
Example fix
// before
const client = await toolset.getApiClient(); // throws
const tools = toolset._generateIntegrationTools(); // use generated tools instead
// after
class MyToolset extends OpenAPIToolset {
async getApiClient() {
return createClient(this.openApiSpec);
}
}
const client = await new MyToolset(spec).getApiClient(); Defensive patterns
Strategy: fallback
Validate before calling
if (toolset.getApiClient === OpenAPIToolset.prototype.getApiClient) {
// base toolset has no client; use generated tools instead
} Type guard
function hasApiToolsetClient(toolset) {
return typeof toolset.getApiClient === 'function' &&
toolset.getApiClient !== OpenAPIToolset.prototype.getApiClient;
} Try / catch
try {
client = await toolset.getApiClient();
} catch (e) {
if (e.message === 'API not implemented') {
client = null; // use toolset.listTools() / generated tools instead
} else {
throw e;
}
} Prevention
- Use concrete toolset subclasses that bind a real client
- If you only need tools, use the generated integration tools rather than the client
- Override getApiClient when subclassing OpenAPIToolset
- Check for a client before writing code paths that depend on direct API calls
When it happens
Trigger: Calling toolset.getApiClient() (directly or via the client() helper that invokes it) on a plain OpenAPIToolset / base toolset instance that does not override getApiClient with a real client implementation.
Common situations: Instantiating a generic OpenAPI toolset from a spec and then trying to obtain its client for custom calls; helper code assuming every toolset exposes getApiClient; subclassing OpenAPIToolset without wiring the generated client.
Related errors
- Method not implemented
- Platform API request did not return a redirect.
- await extractError(res)
- Method not implemented.
- OBSERVABILITY_STORAGE_BATCH_UPDATE_SPANS_NOT_IMPLEMENTED
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/22492c53f6fdd3b7.
Report an issue: GitHub.