Skip to content

trying to add OpenAI compatible z.AI (GLM-4.7) #1347

@farangkao

Description

@farangkao

i've have tested z.AI with GLM-4.7 (using Coding Plan, which is a very good deal) via my own Python script like this:

from openai import OpenAI

def main():
    client = OpenAI(
        api_key="secret-api-key",
        base_url="https://api.z.ai/api/coding/paas/v4"
    )

    try:
        response = client.chat.completions.create(
            model="glm-4.7",
            messages=[
                {
                    "role": "user",
                    "content": "Hello! Please introduce yourself and tell me what you can do."
                }
            ],
            max_tokens=500,
            temperature=0.7
        )
 ...

This will work.
I then did the following with "llm":
Adding an api key via llm keys set openai

adding the file ~/.config/io.datasette.llm/extra-openai-models.yaml with content:

- model_id: glm-4.7
 model_name: glm-4.7
 api_base: "https://api.z.ai/api/coding/pass/v4"

then trying to test it with:
llm -m glm-4.7 "Short Description of what an llm is"

but got the error:

Error: Error code: 500 - {'error': {'code': '500', 'message': '404 NOT_FOUND'}}

any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions