AnthropicClient (anthropic/client.ts)

lace · packages/agent/src/providers/anthropic/client.ts · typescript · Apache-2.0
ai

ABOUTME: Anthropic API client for fetching model catalogs ABOUTME: Handles authentication, pagination, and response validation

// Source: https://github.com/obra/lace | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// ABOUTME: Anthropic API client for fetching model catalogs
// ABOUTME: Handles authentication, pagination, and response validation

import { AnthropicModel, AnthropicModelsResponse, AnthropicModelsResponseSchema } from './types';

export class AnthropicClient {
  private baseUrl: string;

  constructor(baseUrl?: string) {
    this.baseUrl = baseUrl || 'https://api.anthropic.com/v1';
  }

  async fetchModels(apiKey: string, afterId?: string): Promise<AnthropicModelsResponse> {
    const url = new URL(`${this.baseUrl}/models`);
    if (afterId) {
      url.searchParams.set('after_id', afterId);

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key