Saltar al contenido principal

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.

La forma más sencilla es establecer directamente las variables de entorno como se muestra a continuación

Dirección de descarga: https://www.langchain.com/
API_SECRET_KEY = "sk-pvMtoVO******66249058b93C766F2D70167"
BASE_URL = "https://aihubmix.com/v1"; #Base URL for aihubmix

os.environ["OPENAI_API_KEY"] = API_SECRET_KEY
os.environ["OPENAI_BASE_URL"] = BASE_URL
Nota: asegúrate de añadir /v1 al final de openai_api_base.
Python
from langchain.chat_models import ChatOpenAI

llm = ChatOpenAI(
    openai_api_base="https://aihubmix.com/v1", # Note, add /v1 at the end
    openai_api_key="sk-3133f******fee269b71d",
)

res = llm.predict("hello")

print(res)
Código de ejemplo para usar un LLM y realizar predicciones. La clave está, en realidad, en establecer la clave y la URL. Los métodos incluyen:
  1. Configurar mediante variables de entorno
  2. Pasar variables
  3. Establecer manualmente las variables de entorno
Python
import os
import requests
import time
import json
import time
from langchain.llms import OpenAI

API_SECRET_KEY = "your key from aihubmix";
BASE_URL = "https://aihubmix.com/v1"; #Base URL for aihubmix

os.environ["OPENAI_API_KEY"] = API_SECRET_KEY
os.environ["OPENAI_API_BASE"] = BASE_URL

def text():
    llm = OpenAI(temperature=0.9)
    text = "What would be a good company name for a company that makes colorful socks?"
    print(llm(text))

if __name__ == '__main__':
    text();
    
Después de ejecutarlo, verás la respuesta:
Lively Socks.

Última actualización: 2026-06-01