使用CablyAI Chat Completion API时返回助手消息内容为空的问题求助
Hey everyone,
I'm working on a project that requires an AI API with no limitations and versatile functionality. After some research, I found CablyAI—it supports multiple AI models, and some of them are even free with unlimited usage.
I tried implementing its chat completion API (following their official documentation), but ran into an annoying issue: when I send a request, the assistant's message content comes back completely empty.
Here's the code I'm using:
import requests import json data = { "model": "llama-3.1-8b-instruct", # A free model listed on Cably AI "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hello, how are you today?" } ], "stream": False, } header = { "authorization": "Bearer CABLY_AI_BEARER_AUTHORIZATION", # Replaced with my valid token "accept": "application/json", "content-type": "application/json" } # I've tried both using `json=data` directly and `data=json.dumps(data, indent=2)` response = requests.post( "https://cablyai.com/v1/chat/completions", data=json.dumps(data, indent=2), headers=header ) print(json.loads(response.text))
And here's the output I get after using a valid bearer token:
{ 'id': 'chatcmpl-123', 'object': 'chat.completion', 'created': 1677652288, 'model': 'o3-mini-low', 'choices': [ { 'index': 0, 'message': {'role': 'assistant', 'content': ''}, 'finish_reason': 'stop' } ], 'usage': {'prompt_tokens': 0, 'completion_tokens': 0, 'total_tokens': 0} }
You can see the content field in the assistant's message is empty, and all token usage counts are 0. I've double-checked that my bearer token is valid, and tested both request body formats (direct json=data and serialized json.dumps()), but the result is the same.
Has anyone else encountered this issue with CablyAI's API? Any thoughts on what might be causing this or how to fix it?
内容来源于stack exchange

