xtekky / gpt4free

The official gpt4free repository | various collection of powerful language models
https://g4f.ai
GNU General Public License v3.0
62.35k stars 13.4k forks source link

how to use blackbox provider using API? #2374

Closed zing75blog closed 1 week ago

zing75blog commented 1 week ago

I have seen the documentation about the api, but I just want to know if my code is correct?

because from the response it doesn't seem like the claude model and is it possible to use web search parameters in the API?

this is my code:

import requests

url = "http://localhost:1337/v1/chat/completions"

body = {
    "model": "claude-sonnet-3.5",
    "stream": False,
    "messages": [
        {"role": "user", "content": "hello"}
    ],
    "provider": "Blackbox",
    "web_search": True
}

json_response = requests.post(url, json=body).json().get('choices', [])

for choice in json_response:
    print(choice.get('message', {}).get('content', ''))
hlohaus commented 1 week ago

Could you please clarify why you believe it is not a Claude model? Additionally, the web_search option is not currently supported in the API.

zing75blog commented 1 week ago

sorry this was my mistake now the sonnet model is working fine