New

    Introducing AutoEvals: Find the right model for your task

    Z.aiText Generation Model

    GLM-5

    Z.ai's open-weight GLM-5, MIT-licensed, with a 200K-token context and a thinking toggle for reasoning-heavy prompts. An economical default for chat, extraction, and agentic tool use when the newer 5.2/5.3 tiers are more than a task needs.

    import OpenAI from "openai";
    
    const openai = new OpenAI({
      baseURL: "https://api.inference.net/v1",
      apiKey: "<YOUR_API_KEY>",
    });
    
    const completion = await openai.chat.completions.create({
      model: "glm-5",
      messages: [
        {
          role: "user",
          content: "What is the meaning of life?"
        }
      ],
      stream: true,
    });
    
    for await (const chunk of completion) {
      process.stdout.write(chunk.choices[0]?.delta.content as string);
    }
    Prompt caching
    1. Keep the prompt prefix stable and byte-identical across calls.
    2. Pass a stable session_id for routing stickiness and a stable prompt_cache_key for cache affinity.
    3. Check usage.prompt_tokens_details.cached_tokens in the response to confirm cache reads.
    {
      "session_id": "my-stable-session",
      "prompt_cache_key": "v1-stable-prefix",
      "messages": [{ "role": "user", "content": "..." }]
    }

    Start building with GLM-5 today

    Serverless, OpenAI-compatible, and billed per token. No commitments.