概述
集成细节
模型特性
设置
要访问 AI/ML API 模型,您需要创建一个账户,获取一个 API 密钥,并安装langchain-aimlapi 集成包。
凭证
前往 aimlapi.com 注册并生成 API 密钥。完成后,设置AIMLAPI_API_KEY 环境变量:
安装
LangChain AI/ML API 集成位于langchain-aimlapi 包中:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
使用 LangChain Python 集成 AIMLAPI LLM。
| 类 | 包 | 本地 | 可序列化 | JS 支持 | 下载 | 版本 |
|---|---|---|---|---|---|---|
AimlapiLLM | langchain-aimlapi | ❌ | beta | ❌ |
langchain-aimlapi 集成包。
AIMLAPI_API_KEY 环境变量:
import getpass
import os
if not os.getenv("AIMLAPI_API_KEY"):
os.environ["AIMLAPI_API_KEY"] = getpass.getpass("Enter your AI/ML API key: ")
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
langchain-aimlapi 包中:
pip install -qU langchain-aimlapi
from langchain_aimlapi import AimlapiLLM
llm = AimlapiLLM(
model="openai/gpt-5-5",
temperature=0.5,
max_tokens=1024,
)
response = llm.invoke("Explain the bubble sort algorithm in Python.")
print(response)
Bubble sort is a simple sorting algorithm that repeatedly steps through a list, compares adjacent items, and swaps them when they are out of order. The process repeats until the entire list is sorted. While easy to understand and implement, bubble sort is inefficient on large datasets because it has quadratic time complexity.