Used the following test script to check the context window but fails at even ~1000 tokens.
import argparse
from openai import OpenAI
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--api_key", required=True)
parser.add_argument("--base_url", required=True)
args = parser.parse_args()
client = OpenAI(base_url=args.base_url, api_key=args.api_key)
# Test usually safe lengths
token_counts = [1000, 4000, 8000, 16000, 32000]
print(f"Testing endpoint: {args.base_url}")
for tokens in token_counts:
print(f"\nTesting prompt size: ~{tokens} tokens...", end=" ", flush=True)
# Create a dummy prompt of roughly 'tokens' length (1 token ~= 4 chars)
prompt = "test " * tokens
try:
response = client.chat.completions.create(
model="zai-org/GLM-5-FP8",
messages=[{"role": "user", "content": prompt}],
max_tokens=10,
temperature=0
)
content = response.choices[0].message.content
reason = response.choices[0].finish_reason
if content is None or reason == "length":
print("❌ FAILED (Context Limit Hit)")
print(f" -> The endpoint cannot handle {tokens} tokens.")
break
else:
print("✅ SUCCESS")
except Exception as e:
print(f"❌ ERROR: {e}")
break
if __name__ == "__main__":
main()
uv run python test_limit.py \
--api_key "<token>" \
--base_url "https://api.us-west-2.modal.direct/v1"
Testing endpoint: https://api.us-west-2.modal.direct/v1
Testing prompt size: ~1000 tokens... ❌ FAILED (Context Limit Hit)
-> The endpoint cannot handle 1000 tokens.
Used the following test script to check the context window but fails at even ~1000 tokens.