You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Python请求Incogniton Profile API接口?含接口说明及访问异常

如何用Python调用Incogniton Profile API

前提准备

  • 确保Incogniton客户端正在运行(API服务由客户端提供,关闭后接口失效)
  • 安装requests库:执行命令 pip install requests

常用接口调用示例

1. 启动指定配置文件(默认模式)

import requests

profile_id = "你的Profile_ID"
port = 35000  # 若修改过端口,替换为auth.json文件中的对应值

url = f"http://localhost:{port}/profile/launch/{profile_id}"
response = requests.get(url)

if response.status_code == 200:
    print("配置文件启动成功")
else:
    print(f"请求失败,状态码:{response.status_code},响应内容:{response.text}")

2. 使用本地数据启动配置文件

import requests

profile_id = "你的Profile_ID"
port = 35000

url = f"http://localhost:{port}/profile/launch/{profile_id}/local"
response = requests.get(url)

if response.status_code == 200:
    print("本地数据模式启动成功")
else:
    print(f"请求失败:{response.status_code} - {response.text}")

3. 使用云端数据启动配置文件

import requests

profile_id = "你的Profile_ID"
port = 35000

url = f"http://localhost:{port}/profile/launch/{profile_id}/cloud"
response = requests.get(url)

if response.status_code == 200:
    print("云端数据模式启动成功")
else:
    print(f"请求失败:{response.status_code} - {response.text}")

4. 停止指定配置文件

import requests

profile_id = "你的Profile_ID"
port = 35000

url = f"http://localhost:{port}/profile/stop/{profile_id}"
response = requests.get(url)

if response.status_code == 200:
    print("配置文件已停止")
else:
    print(f"请求失败:{response.status_code} - {response.text}")

5. 删除指定配置文件

import requests

profile_id = "你的Profile_ID"
port = 35000

url = f"http://localhost:{port}/profile/delete/{profile_id}"
response = requests.get(url)

if response.status_code == 200:
    print("配置文件已删除")
else:
    print(f"请求失败:{response.status_code} - {response.text}")

6. 获取所有配置文件信息

import requests

port = 35000

url = f"http://localhost:{port}/profile/all"
response = requests.get(url)

if response.status_code == 200:
    profiles = response.json()
    print("所有配置文件信息:")
    for profile in profiles:
        print(f"ID: {profile['id']}, 名称: {profile['name']}")
else:
    print(f"请求失败:{response.status_code} - {response.text}")

浏览器访问API无响应的排查步骤
  1. 确认Incogniton客户端处于运行状态:API依赖客户端提供服务,关闭客户端后接口会直接失效。
  2. 验证端口正确性:
    • 默认端口为35000,若修改过,打开C:/Users/%username%/incogniton/auth.json文件,查找port字段确认当前端口。
    • 浏览器中使用正确端口测试,比如端口改为36000,就访问http://localhost:36000/profile/all验证。
  3. 检查本地端口监听状态:
    • Windows系统:打开命令提示符,执行 netstat -ano | findstr :35000,查看是否有进程占用该端口。
    • macOS/Linux系统:打开终端,执行 lsof -i :35000 或 ss -tulpn | grep :35000,确认端口是否被Incogniton相关进程监听。
  4. 排查防火墙/安全软件拦截:临时关闭Windows Defender或第三方杀毒软件,重新尝试访问接口,若能正常访问则需将Incogniton客户端加入白名单。
  5. 确认Profile_ID有效性:先调用/profile/all接口获取所有有效配置文件ID,再用正确的ID测试/profile/launch/[PROFILE-ID]。
  6. 检查请求方式:部分API可能要求使用POST方法,浏览器默认发送GET请求,可尝试用curl或Postman工具发送POST请求测试接口是否正常。

内容的提问来源于stack exchange,提问作者Ravichandran Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 20:32:37