> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiekou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Compatible con Anthropic SDK

export const AnthropicCompatibilityModels = () => {
  if (typeof document === "undefined") {
    return null;
  } else {
    let attempts = 0;
    const maxAttempts = 50;
    const INIT_DISPLAY_COUNT = 3;
    const interval = setInterval(() => {
      const clientComponent = document.getElementById("anthropic-compatibility-models");
      if (clientComponent && window.jiekouRemoteData.llmModels.status === 'loaded') {
        const modelList = window.jiekouRemoteData.llmModels.data.filter(model => {
          return (model.endpoints || []).includes('anthropic');
        });
        let displayModels = modelList.slice(0, INIT_DISPLAY_COUNT).map(model => {
          return `<li><span class="model-id-item">${model.id}</span></li>`;
        }).join('');
        let showMoreButton = '';
        if (modelList.length > INIT_DISPLAY_COUNT) {
          showMoreButton = `<button id="show-more-anthropic-compatibility-model-btn" style="margin-left: 32px; color: rgb(40 116 255)">查看更多</button>`;
        }
        clientComponent.innerHTML = `
          <ul>${displayModels}</ul>
          ${showMoreButton}
        `;
        document.getElementById('show-more-anthropic-compatibility-model-btn')?.addEventListener('click', () => {
          clientComponent.innerHTML = `
            <ul>${modelList.map(model => {
            return `<li><span class="model-id-item">${model.id}</span></li>`;
          }).join('')}</ul>
          `;
        });
        clearInterval(interval);
      }
      attempts++;
      if (attempts >= maxAttempts) {
        clearInterval(interval);
      }
    }, 200);
    return <div id="anthropic-compatibility-models"></div>;
  }
};

JieKou AI proporciona un servicio de API compatible con Anthropic SDK para que pueda integrarlo fácilmente en sus aplicaciones existentes. Si ya ha desarrollado una aplicación con Anthropic SDK, solo necesita reemplazar la base URL y la API Key por la dirección de API y la API Key de JieKou AI. Consulte la guía de integración a continuación.

## Modelos compatibles

Actualmente, solo los siguientes modelos ofrecen compatibilidad con Anthropic SDK:

<AnthropicCompatibilityModels />

## Inicio rápido

### 1. Instalar Anthropic SDK

<CodeGroup>
  ```bash Python icon="python" theme={null}
  pip install anthropic
  ```

  ```bash TypeScript icon="js" theme={null}
  npm install @anthropic-ai/sdk
  ```
</CodeGroup>

### 2. Inicializar el cliente

Anthropic SDK intentará obtener la API Key y la base URL desde las variables de entorno `ANTHROPIC_API_KEY` y `ANTHROPIC_BASE_URL`, respectivamente. También puede especificarlas mediante parámetros al inicializar el cliente.

* Configuración basada en variables de entorno

<CodeGroup>
  ```bash Bash icon="terminal" theme={null}
  export ANTHROPIC_BASE_URL="https://api.highwayapi.ai/anthropic"
  export ANTHROPIC_API_KEY="<JieKou AI  API Key>"
  ```
</CodeGroup>

* Configuración de parámetros al inicializar el cliente de Anthropic

<CodeGroup>
  ```python Python icon="python" theme={null}
  import anthropic

  client = anthropic.Anthropic(
      base_url="https://api.highwayapi.ai/anthropic",
      api_key="<JieKou AI  API Key>",
      # Sobrescribir header
      default_headers={
          "Content-Type": "application/json",
          "Authorization": "Bearer <JieKou AI  API Key>",
      }
  )
  ```

  ```typescript TypeScript icon="js" theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const anthropic = new Anthropic({
      baseURL: "https://api.highwayapi.ai/anthropic",
      apiKey: "<JieKou AI  API Key>",
      // Sobrescribir header
      defaultHeaders: {
        "Content-Type": "application/json",
        Authorization: `Bearer <JieKou AI  API Key>`,
      }
  });
  ```
</CodeGroup>

### 3. Llamar a la API

<CodeGroup>
  ```python Python icon="python" theme={null}
  import anthropic

  # Inicialice el cliente. Si ya ha configurado la API Key y la base URL
  # mediante las variables de entorno `ANTHROPIC_BASE_URL` y `ANTHROPIC_API_KEY`,
  # puede omitir los parámetros `api_key` y `base_url`.
  client = anthropic.Anthropic(
      base_url="https://api.highwayapi.ai/anthropic",
      api_key="<JieKou AI  API Key>",
      # Sobrescribir header
      default_headers={
          "Content-Type": "application/json",
          "Authorization": "Bearer <JieKou AI  API Key>",
      }
  )

  message = client.messages.create(
      model="moonshotai/kimi-k2-instruct",
      max_tokens=1000,
      temperature=1,
      system=[
          {
              "type": "text",
              "text": "Eres el asistente de IA de JieKou AI; ayudarás a los usuarios con una actitud honesta y profesional, y responderás las preguntas en español."
          }
      ],
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "text",
                      "text": "¿Quién eres?"
                  }
              ]
          }
      ]
  )

  print(message.content)
  ```

  ```typescript TypeScript icon="js" theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  // Inicialice el cliente. Si ya ha configurado la API Key y la base URL
  // mediante las variables de entorno `ANTHROPIC_BASE_URL` y `ANTHROPIC_API_KEY`,
  // puede omitir los parámetros `baseURL` y `apiKey`.
  const anthropic = new Anthropic({
      baseURL: "https://api.highwayapi.ai/anthropic",
      apiKey: "<JieKou AI  API Key>",
      // Sobrescribir header
      defaultHeaders: {
        "Content-Type": "application/json",
        Authorization: `Bearer <JieKou AI  API Key>`,
      },
  });

  const msg = await anthropic.messages.create({
    model: "moonshotai/kimi-k2-instruct",
    max_tokens: 1000,
    temperature: 1,
    system: "Eres el asistente de IA de JieKou AI; ayudarás a los usuarios con una actitud honesta y profesional, y responderás las preguntas en español.",
    messages: [
      {
        role: "user",
        content: [
          {
            type: "text",
            text: "¿Quién eres?"
          }
        ]
      }
    ]
  });

  console.log(msg);
  ```
</CodeGroup>
