Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

免费的api报错 #351

Open
xulw8 opened this issue Jan 14, 2025 · 1 comment
Open

免费的api报错 #351

xulw8 opened this issue Jan 14, 2025 · 1 comment

Comments

@xulw8
Copy link

xulw8 commented Jan 14, 2025

我自己去官网搞的api不会报这个错,但是就是说没额度,但是申请了免费的api报错如下,请问大佬如何解决,如果能用,后续会考虑付费使用image

@ynpl
Copy link

ynpl commented Jan 15, 2025

没改api地址 转发api要修改api地址的哦

from openai import OpenAI

client = OpenAI(
    # 输入转发API Key
    api_key="sk-xxxxxxx",
    base_url="https://api.chatanywhere.tech/v1"
)

completion = client.chat.completions.create(
    model="gpt-3.5-turbo-1106",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "你是谁!"}
    ],
    logprobs=True,
    
    stream=True  # 是否开启流式输出
)

# 非流式输出获取结果
# print(completion.choices[0].message)
# 流式输出获取结果
for chunk in completion:
    print(chunk.choices[0].delta)
''''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants