沃卡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请求示例(图片分析示例)

import requests
import json

def analyze_image(image_url, api_url, openai_key):
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {openai_key}'
    }

    data = {
        "model": "gpt-4-vision-preview",
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What’s in this image?"},
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": image_url,
                        },
                    },
                ],
            }
        ],
        "max_tokens": 4000,
    }

    response = requests.post(api_url, headers=headers, data=json.dumps(data))

    print(response.json())

# 使用方法
analyze_image("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", "https://4.0.wokaai.com/v1/chat/completions", "sk-xxxxxxx")
上一页
通过 流式请求示例(chat示例)
下一页
【必读】API地址(Base Url)
Built with