Skip to main content

LlamaIndex

1.1 Usage

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
model="minimax/minimax-m2.5",
api_base="https://api.hpc-ai.com/inference/v1",
api_key="your-hpc-ai-api-key",
is_chat_model=True
)

response = llm.complete("Hello, how are you?")
print(response.text)

Method 2: OpenAI Class

from llama_index.llms.openai import OpenAI

llm = OpenAI(
model="minimax/minimax-m2.5",
api_base="https://api.hpc-ai.com/inference/v1",
api_key="your-hpc-ai-api-key"
)

Method 3: Global Default LLM

from llama_index import Settings
from llama_index.llms.openai_like import OpenAILike

Settings.llm = OpenAILike(
model="minimax/minimax-m2.5",
api_base="https://api.hpc-ai.com/inference/v1",
api_key="your-hpc-ai-api-key",
is_chat_model=True,
is_function_calling_model=True
)

Method 4: RAG Pipeline

from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.llms.openai_like import OpenAILike

documents = SimpleDirectoryReader("data").load_data()

llm = OpenAILike(
model="minimax/minimax-m2.5",
api_base="https://api.hpc-ai.com/inference/v1",
api_key="your-hpc-ai-api-key",
is_chat_model=True
)

index = VectorStoreIndex.from_documents(documents, llm=llm)
query_engine = index.as_query_engine()
response = query_engine.query("What is the document about?")

1.2 Troubleshooting

Common IssueSolution
is_chat_model errorsSet to True (Chat) or False (Completion) per model type
Function calling not workingSet is_function_calling_model=True

1.3 References