AI Personal Learning
and practical guidance
Beanbag Marscode1

Genspark2api (failed)

General Introduction

genspark2api 是一个开源的 API 服务工具,托管在 GitHub 上,由开发者 deanxv 创建。它提供了一个支持多模型对话、文生图和文生视频的接口服务,用户可以通过 Docker 快速部署在本地或服务器上。这个工具的核心功能是让开发者轻松调用多种对话模型(如 gpt-4o、claude-3-5-sonnet)和生成工具(如 flux、dall-e-3),支持联网搜索和图片识别等多轮对话。项目版本目前为 3.4,代码完全公开,用户可以自由修改。它的设计目标是简化开发流程,适合技术爱好者或小型团队使用。

 

Function List

  • 支持多种对话模型接口(流式和非流式),如 gpt-4o,claude-3-5-sonnet,未支持模型会自动切换到 Mixture-of-Agents 模式。
  • 提供联网搜索功能,在模型名后加 -search 即可使用,例如 gpt-4o-searchThe
  • 支持图片和文件识别的多轮对话,用户可以上传内容进行交互。
  • 提供文生图接口 /images/generations,支持模型如 flux,dall-e-3The
  • 支持文生视频和图生视频接口 /videos/generations,可用模型包括 kling/v1.6/standardThe
  • 通过 cookie 池和自动重试机制提升服务稳定性。
  • 支持自定义接口密钥(API_SECRET)和代理配置(PROXY_URL).
  • 允许绑定模型和对话,防止模型切换导致响应质量下降。

 

Using Help

Installation process

genspark2api 依赖 Docker 部署,适合有基础技术能力的用户。以下是详细步骤:

  1. Installing Docker
    在电脑或服务器上安装 Docker。访问 https://www.docker.com/ 下载并安装。安装后运行以下命令确认:
docker --version

如果显示版本号,说明环境就绪。

  1. Pulling Mirrors
    在终端输入命令拉取最新镜像:
docker pull deanxv/genspark2api:latest

如果拉取失败,可用 GitHub 镜像:

docker pull ghcr.io/deanxv/genspark2api:latest
  1. Configuring Environment Variables
    创建一个本地文件夹(如 . /data)存储数据。准备以下变量:
  • GS_COOKIE: from genspark 官网获取的 cookie,多个用逗号分隔。
  • API_SECRET:自定义密钥,如 "123456",用于接口安全校验。
  • TZ:时区,如 "Asia/Shanghai"。
    示例运行命令:
docker run --name genspark2api -d --restart always 
-p 7055:7055 
-v ./data:/app/genspark2api/data 
-e GS_COOKIE="session_id=你的cookie" 
-e API_SECRET="123456" 
-e TZ="Asia/Shanghai" 
deanxv/genspark2api:latest
  1. 启动并验证
    运行后,访问 http://localhost:7055 检查服务状态。如果需要查看日志:
docker logs genspark2api

获取 cookie

  1. 打开浏览器,按 F12 进入开发者工具。
  2. interviews https://www.genspark.ai,发起一次对话。
  3. 在“网络”选项卡中找到 ask 请求,复制请求头中的 cookie 值。
    Must contain,session_id=xxx,, other parts are optional. ,,Use dialog interface,dialog interface path is ,,Streaming and non-streaming output is supported. ,(non-streaming):,curl -X POST http://localhost:7055/chat/completions -H "Authorization: Bearer 123456" -H "Content-Type: application/json" -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "hello"}]}',,Data will be returned in chunks. ,return example,{"choices": [{"message": {"role": "assistant", "content": "Hello! How can I help you?"}}]} ,Use the text-generated image interface, path to ,, to support generating images. ,curl -X POST http://localhost:7055/images/generations -H "Authorization: Bearer 123456" -H "Content-Type: application/json" -d '{"model": "flux", "prompt": "A cat playing in the grass"}',{"data": [{"url": "https://example.com/image.jpg"}]},,Use the Vincennes video interface,, which supports generating videos from text or images. ,(text generation):,curl -X POST http://localhost:7055/videos/generations -H "Authorization: Bearer 123456" -H "Content-Type: application/json" -d '{"model": "kling/v1.6/standard", "prompt": "City Night View", "aspect_ratio": "16:9", "duration": 10, "auto_prompt": true}',{"created": 1677664796, " data": [{"url": "https://example.com/video.mp4"}]},Configure ReCaptcha validation, officially required by ReCaptchaV3 validation, otherwise the model may be downgraded or generated abnormally. Need to work with,genspark-playwright-proxy,service:,Deploy proxy service:,docker run --name genspark-playwright-proxy -d --restart always -p 7022:7022 -v . /data:/app/genspark-playwright-proxy/data -e TZ="Asia/Shanghai" deanxv/genspark-playwright-proxy:latest, add environment variable in genspark2api: ,-e RECAPTCHA_PROXY_URL="http://127.0.0.1:7022", restart service to take effect. ,The interface returns "All cookies are temporarily unavailable",All cookies reached rate limit. Replace them with new ones, or wait for a while. ,Encounter Cloudflare interception,-e PROXY_URL="http://127.0.0.1:10801",Quickly build a customer service bot through the dialog interface to support networked searches and multiple rounds of dialog to answer customer questions. ,Generate Creative Content,Use the text-to-graphics and text-to-video features to enter descriptions to generate images or short videos for design prototyping or social media content. For education and technical learning, students or developers can deploy the service, call different models for experimentation, and learn about APIs and model integration. What dialog models are supported? A variety of models are supported, such as , and models not listed will trigger Mixture-of-Agents mode. What should I do if I fail to use RECAPTCHART? RECAPTCHA_PROXY_URL, is it configured correctly, make sure it passes ReCaptchaV3 validation. ,How to improve the stability of the service? ,Configure multiple,,Enable cookie pooling and auto switch when request fails. ,genspark2api is an open source reverse API tool that supports multi-model conversations, text-to-graph and text-to-video. Deployed via Docker, it can be run by users with simple commands to provide streaming output, networked search, and image recognition, and it can be configured with cookie pools and keys to improve stability and security. Genspark2api-Chief AI Sharing Circle session_id=xxx,其他部分可选。

使用对话接口

对话接口路径为 /chat/completions,支持流式和非流式输出。

  • Example of a request(非流式):
curl -X POST http://localhost:7055/chat/completions 
-H "Authorization: Bearer 123456" 
-H "Content-Type: application/json" 
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "你好"}]}'
  • streaming output: Add "stream": true,数据会分块返回。
  • 返回示例::
{"choices": [{"message": {"role": "assistant", "content": "你好!有什么可以帮助你的吗?"}}]}

使用文生图接口

路径为 /images/generations,支持生成图片。

  • Example of a request::
curl -X POST http://localhost:7055/images/generations 
-H "Authorization: Bearer 123456" 
-H "Content-Type: application/json" 
-d '{"model": "flux", "prompt": "一只猫在草地上玩耍"}'
  • 返回示例::
{"data": [{"url": "https://example.com/image.jpg"}]}

使用文生视频接口

路径为 /videos/generations,支持文本或图片生成视频。

  • Example of a request(文本生成):
curl -X POST http://localhost:7055/videos/generations 
-H "Authorization: Bearer 123456" 
-H "Content-Type: application/json" 
-d '{"model": "kling/v1.6/standard", "prompt": "城市夜景", "aspect_ratio": "16:9", "duration": 10, "auto_prompt": true}'
  • 返回示例::
{"created": 1677664796, "data": [{"url": "https://example.com/video.mp4"}]}

配置 ReCaptcha 验证

官方要求通过 ReCaptchaV3 验证,否则模型可能降智或生成异常。需要配合 genspark-playwright-proxy 服务:

  1. 部署代理服务:
docker run --name genspark-playwright-proxy -d --restart always 
-p 7022:7022 
-v ./data:/app/genspark-playwright-proxy/data 
-e TZ="Asia/Shanghai" 
deanxv/genspark-playwright-proxy:latest
  1. 在 genspark2api 中添加环境变量:
-e RECAPTCHA_PROXY_URL="http://127.0.0.1:7022"
  1. 重启服务生效。

Frequently Asked Questions

  • 接口返回 "All cookies are temporarily unavailable"
    所有 cookie 达到速率限制。更换新的 GS_COOKIE 或等待一段时间。
  • 遇到 Cloudflare 拦截
    configure PROXY_URLe.g. -e PROXY_URL="http://127.0.0.1:10801"The

 

application scenario

  1. Developing Intelligent Customer Service
    通过对话接口快速搭建客服机器人,支持联网搜索和多轮对话,回答客户问题。
  2. 生成创意内容
    使用文生图和文生视频功能,输入描述生成图片或短视频,用于设计原型或社交媒体内容。
  3. 教育和技术学习
    学生或开发者可以部署服务,调用不同模型进行实验,学习 API 和模型集成。

 

QA

  1. 支持哪些对话模型?
    be in favor of gpt-4o,claude-3-5-sonnet 等多种模型,未列出模型会触发 Mixture-of-Agents 模式。
  2. 文生图失败怎么办?
    probe RECAPTCHA_PROXY_URL 是否配置正确,确保通过 ReCaptchaV3 验证。
  3. 如何提升服务稳定性?
    配置多个 GS_COOKIE,启用 cookie 池,请求失败时自动切换。

May not be reproduced without permission:Chief AI Sharing Circle " Genspark2api (failed)
en_USEnglish