#807·InternLM

[Feature] Puyu API Support usage

Author: vansinCreated Nov 21, 2024Updated May 2, 2026
Labelsenhancement

Describe the feature

image

usage is None, Please support it !!!

python

from openai import OpenAI

key =  'puyuapi key'


client = OpenAI(
    api_key=key,  # 此处传token,不带Bearer
    base_url="https://internlm-chat.intern-ai.org.cn/puyu/api/v1/",
)

chat_rsp = client.chat.completions.create(
    model="internlm2.5-latest",
    messages=[{"role": "user", "content": "hello"}],
)

for choice in chat_rsp.choices:
    print(choice.message.content)

such like that

json
    "id": "chatcmpl-6q0Kqgk2qlcpCGDYcLQnUmUVVrMd6",
    "object": "chat.completion",
    "created": 1677852364,
    "model": "gpt-3.5-turbo-0301",
    "usage": {
        "prompt_tokens": 69,
        "completion_tokens": 20,
        "total_tokens": 89
    },
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "起草一封电子邮件或其他写作材料。"
            },
            "finish_reason": "stop",
            "index": 0
        }
    ]
}

siliconflow support usage

python
from openai import OpenAI

key = 'sk-xxxxxxx'


client = OpenAI(
    api_key=key,  # 此处传token,不带Bearer
    base_url="https://api.siliconflow.cn/v1/",
)

chat_rsp = client.chat.completions.create(
    model="internlm/internlm2_5-7b-chat",
    messages=[{"role": "user", "content": "hello"}],
)

for choice in chat_rsp.choices:
    print(choice.message.content)

img_v3_02gr_658adf49-790b-4c80-8a1e-6211575d8fdg

Will you implement it?

  • I would like to implement this feature and create a PR!