{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "fee9c5bf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "401\n", "{'code': 'INVALID_API_KEY', 'message': 'Invalid API key'}\n" ] } ], "source": [ "import requests\n", "\n", "base_url = \"https://console.pivotbak.cfd/v1\"\n", "api_key = \"sk-e5246cf15eed1c8c1b94f172c95115de3ae5413eaa5b0366810fa7842de6ada1\"\n", "\n", "resp = requests.get(\n", " f\"{base_url}/models\",\n", " headers={\n", " \"Authorization\": f\"Bearer {api_key}\",\n", " \"Content-Type\": \"application/json\",\n", " },\n", " timeout=30,\n", ")\n", "\n", "print(resp.status_code)\n", "print(resp.json())" ] }, { "cell_type": "code", "execution_count": 11, "id": "c479e82c", "metadata": {}, "outputs": [ { "ename": "ModuleNotFoundError", "evalue": "No module named 'curl_cffi'", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[11], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mos\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mcurl_cffi\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m requests\n\u001b[0;32m 4\u001b[0m BASE_URL \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://console.pivotbak.cfd/v1\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 5\u001b[0m API_KEY \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msk-e5246cf15eed1c8c1b94f172c95115de3ae5413eaa5b0366810fa7842de6ada1\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'curl_cffi'" ] } ], "source": [ "import os\n", "from curl_cffi import requests\n", "\n", "BASE_URL = \"https://console.pivotbak.cfd/v1\"\n", "API_KEY = \"sk-e5246cf15eed1c8c1b94f172c95115de3ae5413eaa5b0366810fa7842de6ada1\"\n", "\n", "headers = {\n", " \"Authorization\": f\"Bearer {API_KEY}\",\n", " \"x-api-key\": API_KEY,\n", " \"Accept\": \"*/*\",\n", " \"Content-Type\": \"application/json\",\n", " \"sec-ch-ua-platform\": '\"Windows\"',\n", " \"sec-ch-ua\": '\"Not-A.Brand\";v=\"24\", \"Chromium\";v=\"146\"',\n", " \"sec-ch-ua-mobile\": \"?0\",\n", " \"x-title\": \"Cherry Studio\",\n", " \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) CherryStudio/1.9.9 Chrome/146.0.7680.188 Electron/41.2.1 Safari/537.36\",\n", " \"HTTP-Referer\": \"https://cherry-ai.com\",\n", " \"Sec-Fetch-Site\": \"cross-site\",\n", " \"Sec-Fetch-Mode\": \"cors\",\n", " \"Sec-Fetch-Dest\": \"empty\",\n", " \"Accept-Encoding\": \"gzip, deflate, br, zstd\",\n", " \"Accept-Language\": \"zh-CN\",\n", " \"Priority\": \"u=1, i\",\n", "}\n", "\n", "resp = requests.get(\n", " f\"{BASE_URL}/models\",\n", " headers=headers,\n", " impersonate=\"chrome136\",\n", " timeout=30,\n", ")\n", "\n", "print(\"status:\", resp.status_code)\n", "print(resp.text)" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }