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

# Guía completa de integración con AIHubMix

> Guía integral para entender los métodos universales de invocación de modelos de AIHubMix

AIHubMix utiliza la interfaz de invocación de modelos de OpenAI como estándar, agregando múltiples modelos, entre ellos OpenAI, Google Gemini, Anthropic Claude y otras series de modelos. Llamar a cualquier modelo se hace con el mismo método; solo es necesario modificar el `model ID` correspondiente.

<Tip>
  Puntos clave: Solo es necesario añadir la `base_url` de reenvío y la [clave API](https://aihubmix.com/token) de la plataforma AiHubMix dentro del cliente. Los IDs de modelo pueden obtenerse pulsando el "Botón Copiar" en las [tarjetas del marketplace de modelos](https://aihubmix.com/models).
</Tip>

## Integración básica: uso de la biblioteca oficial de OpenAI

### Ejemplo en Python

```py Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-***", # Replace with your AiHubMix generated API key
    base_url="https://aihubmix.com/v1"
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-4o-mini",  # Replace with any supported model ID
)

print(chat_completion)
```

<Info>
  Consulta el estado actual del servicio oficial de OpenAI [aquí](https://status.openai.com/)
</Info>

## API universal de reenvío de modelos

Endpoint: `POST` /v1/chat/completions

**Parámetros de la solicitud (Body):**

```json theme={null}
{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
}
```

### Parámetros de la solicitud

| Nombre        | Ubicación | Tipo   | Obligatorio | Descripción               |
| ------------- | --------- | ------ | ----------- | ------------------------- |
| Authorization | header    | string | No          | Bearer AIHUBMIX\_API\_KEY |
| Content-Type  | header    | string | No          | ninguno                   |
| body          | body      | object | No          | ninguno                   |

**Ejemplo de respuesta:**

```json theme={null}
200 Response
```

```json theme={null}
{
  "id": "chatcmpl-AzJqsyf2h02BKjrqHMA1HVUQpiDfL",
  "model": "gpt-4o-mini",
  "object": "chat.completion",
  "created": 1739177682,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The meaning of life is a philosophical question that has been debated for centuries. Different people and cultures may have different beliefs about the purpose and significance of life. Some believe that the meaning of life is to seek happiness and fulfillment, while others believe in spiritual or religious meanings such as serving a higher power or fulfilling a destiny. Ultimately, the meaning of life may be a deeply personal and individual question that each person must answer for themselves."
      },
      "finish_reason": "stop"
    }
  ],
  "system_fingerprint": "fp_0165350fbb",
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 86,
    "total_tokens": 100
  }
}
```

### Resultados de la respuesta

| Código de estado | Significado del código | Descripción | Modelo de datos |
| ---------------- | ---------------------- | ----------- | --------------- |
| 200              | OK                     | ninguno     | En línea        |

***

Última actualización: 2026-06-01
