LlamaIndex LLM Integration: GMI Cloud
Community LlamaIndex integration for GMI Cloud's OpenAI-compatible inference API. This is not an official GMI Cloud or LlamaIndex project.
Use any of the 70+ text models on GMI Cloud — GLM, DeepSeek, Qwen, Gemini, Llama and more — through the standard LlamaIndex LLM interface.
- Default model:
zai-org/GLM-5.3-Flash(1,048,576-token context) - API base:
https://api.gmi-serving.com/v1 - Auth:
GMI_API_KEY(create a key at console.gmicloud.ai)
Installation
pip install llama-index-llms-gmicloud
Or, from a checkout of this repository:
pip install -e .
# or
uv sync --group dev
Usage
from llama_index.llms.gmicloud import GMICloud
# Reads GMI_API_KEY from the environment
llm = GMICloud()
You can also pass the key and model explicitly:
llm = GMICloud(
model="zai-org/GLM-5.3-Flash",
api_key="your-api-key",
)
Completion
response = llm.complete("Explain the importance of low latency LLMs in two sentences.")
print(response)
Chat
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(role="system", content="You are a concise assistant."),
ChatMessage(role="user", content="Name one use of a 1M-token context window."),
]
response = llm.chat(messages)
print(response.message.content)
Streaming
for chunk in llm.stream_complete("Write a short haiku about clouds."):
print(chunk.delta, end="", flush=True)
Async
import asyncio
async def main():
response = await llm.acomplete("What is 17 * 19?")
print(response)
asyncio.run(main())
Function calling with a FunctionAgent
GMI Cloud's chat completions endpoint accepts OpenAI-style tools. GMICloud sets is_function_calling_model=True by default, so you can drop it into a LlamaIndex agent:
import asyncio
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.gmicloud import GMICloud
def get_weather(city: str) -> str:
"""Return a short weather report for a city."""
return f"Sunny and 22°C in {city}."
agent = FunctionAgent(
tools=[get_weather],
llm=GMICloud(),
system_prompt="You are a helpful assistant. Use tools when they help.",
)
async def main():
response = await agent.run("What's the weather in Paris?")
print(response)
asyncio.run(main())
ReActAgent works the same way if you prefer a text-based reason-act loop:
from llama_index.core.agent.workflow import ReActAgent
agent = ReActAgent(
tools=[get_weather],
llm=GMICloud(),
)
Reasoning models and max_tokens
Some GMI Cloud models (including the default zai-org/GLM-5.3-Flash) put intermediate thinking in reasoning_content and only then write the user-visible reply in content. If max_tokens is too low, the model can spend the entire budget on thinking and return empty content.
GMICloud defaults max_tokens to 2048 to reduce this. If you lower it and get an empty response, raise max_tokens and retry. LlamaIndex already attaches reasoning_content as a thinking block on chat messages; this package also logs a warning when a call comes back reasoning-only.
# Too low: may return empty visible text
llm = GMICloud(max_tokens=16)
# Enough budget for thinking + the visible reply
llm = GMICloud(max_tokens=2048)
Models and context windows
Any model id from GET /v1/models works via the model argument. Context windows for the catalog as of 2026-11-27 are bundled in the package (unknown ids fall back to 1,048,576 tokens). Override with context_window=... if needed.
Examples:
| Model id | Context window |
|---|---|
zai-org/GLM-5.3-Flash (default) |
1,048,576 |
zai-org/GLM-5.3 |
1,048,576 |
deepseek-ai/deepseek-v4.1-flash-1017 |
1,048,575 |
google/gemini-3.8-flash |
1,048,576 |
Qwen/Qwen3.8-27B |
1,000,000 |
Prices change; check the GMI Cloud model library before budgeting.
Configuration
| Parameter | Default | Description |
|---|---|---|
model |
zai-org/GLM-5.3-Flash |
Any GMI Cloud text model id |
api_key |
GMI_API_KEY env var |
GMI Cloud API key |
api_base |
https://api.gmi-serving.com/v1 |
OpenAI-compatible base URL |
is_chat_model |
True |
Use the chat completions endpoint |
is_function_calling_model |
True |
Advertise OpenAI-style tool calling |
context_window |
looked up for the model | Tokens of context |
max_tokens |
2048 |
Max generated tokens (raise this for reasoning models) |
Additional OpenAILike / OpenAI kwargs (temperature, timeout, additional_kwargs, …) are passed through.
Development
uv sync --group dev
uv run ruff check .
uv run pytest
Live API checks are skipped unless both GMI_API_KEY and GMI_LIVE_TEST=1 are set:
GMI_LIVE_TEST=1 uv run pytest tests -m live
# or
GMI_LIVE_TEST=1 python examples/live_check.py
Live verification
Verified on 27 November 2026 (Asia/Calcutta) against the live GMI Cloud API, default model zai-org/GLM-5.3-Flash, LlamaIndex 0.14.26 / llama-index-llms-openai-like 0.9.0:
| Call | Output |
|---|---|
complete |
pong |
stream_complete |
pong |
chat |
pong |
acomplete |
pong |
FunctionAgent (tool: add) |
17 plus 19 equals **36**. |
ReActAgent (tool: add) |
17 plus 19 equals 36. |
A direct tools request also returned tool_calls: get_weather(city="Paris"). With max_tokens=16, the same model returned empty content and a truncated reasoning_content (finish_reason=length), which is why this package defaults max_tokens to 2048 and logs a warning in that case.
License
MIT. See LICENSE.
Metadata
Release files for llama-index-llms-gmicloud 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_llms_gmicloud-0.1.0.tar.gz | 10.3 kB | With provenance | Details for llama_index_llms_gmicloud-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_llms_gmicloud-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_llms_gmicloud-0.1.0-py3-none-any.whl |
Total release size: 18.5 kB
Release files / llama_index_llms_gmicloud-0.1.0.tar.gz
| Download URL | llama_index_llms_gmicloud-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6441379e9cde8eca5fbf9f3f5bef2f8d45d0b57fe65119018fd7577774001523
|
|
BLAKE2b-256 checksum How to use checksums |
31d1dee3d5ab81fd9f81b9181332b743fe13580e4d71f6688797c8de22c5c516
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / llama_index_llms_gmicloud-0.1.0-py3-none-any.whl
| Download URL | llama_index_llms_gmicloud-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8ac660404bdc1b18b56d6550694af0ea94ea488be0616172d0c9e17d6120c52
|
|
BLAKE2b-256 checksum How to use checksums |
730d3352a5487f7e69b0872c08c00659b59b9fb3d15e421cbdbfe5ea41eec031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for llama-index-llms-gmicloud 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for llama_index_llms_gmicloud-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.