> ## 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.

# Guia Completo de Integração AIHubMix

> Guia completo para entender os métodos universais de chamada de modelos da AIHubMix

A AIHubMix utiliza a interface de chamada de modelos da OpenAI como padrão, agregando vários modelos incluindo OpenAI, Google Gemini, Anthropic Claude e outras séries de modelos. Chamar qualquer modelo usa o mesmo método; basta modificar o `model ID` correspondente.

<Tip>
  Pontos-chave: Basta adicionar a `base_url` de encaminhamento e a [chave de API](https://aihubmix.com/token) da plataforma AiHubMix dentro do cliente. Os IDs de modelos podem ser obtidos clicando no "Botão de Cópia" nos [cards do marketplace de modelos](https://aihubmix.com/models).
</Tip>

## Integração Básica: Usando a Biblioteca Oficial da OpenAI

### Exemplo em 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>
  Status atual do serviço oficial da OpenAI [verifique aqui](https://status.openai.com/)
</Info>

## API Universal de Encaminhamento de Modelo

Endpoint: `POST` /v1/chat/completions

**Parâmetros do Corpo da Requisição:**

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

### Parâmetros da Requisição

| Nome          | Localização | Tipo   | Obrigatório | Descrição                 |
| ------------- | ----------- | ------ | ----------- | ------------------------- |
| Authorization | header      | string | Não         | Bearer AIHUBMIX\_API\_KEY |
| Content-Type  | header      | string | Não         | nenhum                    |
| body          | body        | object | Não         | nenhum                    |

**Exemplo de Resposta:**

```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 da Resposta

| Código de Status | Significado do Código | Descrição | Modelo de Dados |
| ---------------- | --------------------- | --------- | --------------- |
| 200              | OK                    | nenhum    | Inline          |

***

Última atualização: 2026-06-01
