沃卡AI使用指南
  1. Python中使用配置
沃卡AI使用指南
  • 引言
  • 关于沃卡中转API
    • 背景介绍
    • 为什么建议您用中转API?
    • 选择沃卡API的理由
  • 简易教程(新手必看)
    • 卡密购买
    • API站内使用教程
    • API接口文档(开发者使用)
  • Python中使用配置
    • Langchain中使用
    • 官方 openai 库中使用
    • 通过request非流式请求示例(chat示例)
    • 通过 流式请求示例(chat示例)
    • 通request请求示例(图片分析示例)
  • 主流AI应用配置教程(免费)
    • 【必读】API地址(Base Url)
    • Chatbox(移动端推荐)
    • ChatGPT Sidebar
    • CherryStudio(桌面应用推荐)
    • Cline
    • Cursor(写代码推荐)
    • Dify(工作流推荐)
    • GPT Academic(学术科研推荐)
    • LobeChat
    • NextChat
    • 沉浸式翻译(翻译推荐)
    • SillyTavern
    • Pot翻译
  • 支持模型列表
    • 大语言模型
    • 文生图模型
    • 文/图生视频模型
    • 其他模型(向量、文本、语音等)
  • 价格详情说明
    • 模型价格说明
    • Token的计算规则
  • 联系我们
    • 微信客服联系方式
    • QQ群
    • 站点列表汇总
  1. Python中使用配置

通过request非流式请求示例(chat示例)

import requests
import json
def get_chat_gpt_response(prompt):
    url = "https://4.0.wokaai.com/v1/chat/completions"
    headers = {
        "Authorization": "Bearer apikey",
        "Content-Type": "application/json"
    }
    data = {
        "model": "claude-3-haiku-20240307",
        "messages": [{"role": "user", "content": prompt}]
    }

    response = requests.post(url, headers=headers, json=data)
    print(json.loads(response.text))
    return response

resp = get_chat_gpt_response('给我画一个可爱的女生穿着绿色的卫衣')
print(resp.text)
上一页
官方 openai 库中使用
下一页
通过 流式请求示例(chat示例)
Built with