Administrator
发布于 2026-03-13 / 15 阅读
0
0

geekerone.top API usage guide

import sys
import os
import asyncio
import httpx

async def test_proxy(token: str):
    base_url = "http://www.geekerone.top"
    endpoint = f"{base_url}/v1/chat/completions"
    
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }
    
    print(f"\nTarget Endpoint: {endpoint}")
    
    # Test 1: Normal Request (Non-stream)
    payload = {
        "model": "qwen-turbo",  # Use qwen-turbo to test with Aliyun Key
        "messages": [{"role": "user", "content": "Hello! Reply with 'Pong'."}],
        "stream": False
    }
    
    print(f"\n--- Testing Normal Request ---")
    try:
        async with httpx.AsyncClient() as client:
            response = await client.post(endpoint, json=payload, headers=headers, timeout=60)
            print(f"Status Code: {response.status_code}")
            if response.status_code == 200:
                print(f"Response Body: {response.json()}")
            else:
                print(f"Error Response: {response.text}")
    except Exception as e:
        print(f"Request failed: {e}")
        print("Tip: Make sure the server is running ")


if __name__ == "__main__":

    token = 'sk-****'
    print(f"Using API Token: {token}")

    
    #  Run 
    asyncio.run(test_proxy(token))


评论