# from openai import OpenAI # #初始化客户端 # client =OpenAI(api_key="sk-ycMJ8Vi9G5Wu0ElwF7B517286d31405dAb27510bDe533a90", base_url="http://45.77.45.137:8000/v1") # # 调用 GPT 模型 # response = client.chat.completions.create(model="gpt-4-turbo", # messages=[ # {"role":"system","content":"你是一个有帮助的助手。"}, # {"role":"user","content":"小明有6个苹果,他又买了两袋苹果,每袋有3个苹果,那么他一共有几个苹果?"} # ], # temperature=0.7 # ) # # 打印响应! # print(response.choices[0].message.content) # import requests # import json # def get_cost_info(api_key): # # 设置请求头 # headers = { # "api-key": api_key # } # # 定义两个API端点 # azure_url = "http://api.gameai-llm.woa.com/llm-service/azure/cost" # gcs_url = "http://api.gameai-llm.woa.com/llm-service/gcs/cost" # try: # # 获取Azure的成本信息 # azure_response = requests.get(azure_url, headers=headers) # azure_data = azure_response.json() # # 获取GCS的成本信息 # gcs_response = requests.get(gcs_url, headers=headers) # gcs_data = gcs_response.json() # # 提取剩余额度信息 # azure_remaining = azure_data.get('result', {}).get('当天剩余额度($)', 0) # gcs_remaining = gcs_data.get('result', {}).get('当天剩余额度($)', 0) # print(f"Azure 剩余额度: ${azure_remaining}") # print(f"GCS 剩余额度: ${gcs_remaining}") # print(f"总剩余额度: ${azure_remaining + gcs_remaining}") # # 打印详细信息 # print("\nAzure 详细信息:") # print(json.dumps(azure_data.get('result', {}), indent=2, ensure_ascii=False)) # print("\nGCS 详细信息:") # print(json.dumps(gcs_data.get('result', {}), indent=2, ensure_ascii=False)) # return azure_remaining + gcs_remaining # except Exception as e: # print(f"获取成本信息时出错: {str(e)}") # return None # if __name__ == "__main__": # # 使用您的API key # api_key = "M4hT7ULYSumBpJ3rREIyf0Xxd286HwKG" # remaining_balance = get_cost_info(api_key) # if remaining_balance is not None: # print(f"\n总剩余额度: ${remaining_balance}") import requests def get_remaining_calls(api_key): headers = {"api-key": api_key} total_remaining = 0 # 查询两个服务的剩余调用次数 for service in ['azure', 'gcs']: url = f"http://api.gameai-llm.woa.com/llm-service/{service}/count" try: response = requests.get(url, headers=headers) data = response.json() remaining = data.get('result', {}).get('当天剩余调用次数', 0) print(f"{service.upper()} 剩余调用次数: {remaining:,}") total_remaining += remaining except Exception as e: print(f"{service} 查询失败: {str(e)}") return total_remaining if __name__ == "__main__": # 使用您的API key api_key = "M4hT7ULYSumBpJ3rREIyf0Xxd286HwKG" total = get_remaining_calls(api_key) print(f"\n总剩余调用次数: {total:,}")