diff options
author | Jakub N <jakubniemczyk97@gmail.com> | 2024-01-22 20:02:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 20:02:42 +0100 |
commit | 430113e94eec662facaf509e64242767d99950a3 (patch) | |
tree | 4b2ad44e482aed528ad1403b1d79b032f8799ce3 | |
parent | Merge pull request #1501 from eltociear/patch-5 (diff) | |
parent | Update README.md (diff) | |
download | gpt4free-430113e94eec662facaf509e64242767d99950a3.tar gpt4free-430113e94eec662facaf509e64242767d99950a3.tar.gz gpt4free-430113e94eec662facaf509e64242767d99950a3.tar.bz2 gpt4free-430113e94eec662facaf509e64242767d99950a3.tar.lz gpt4free-430113e94eec662facaf509e64242767d99950a3.tar.xz gpt4free-430113e94eec662facaf509e64242767d99950a3.tar.zst gpt4free-430113e94eec662facaf509e64242767d99950a3.zip |
-rw-r--r-- | README.md | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -427,6 +427,26 @@ if __name__ == "__main__": main() ``` +## API usage (POST) +#### Chat completions +Send the POST request to /v1/chat/completions with body containing the `model` method. This example uses python with requests library: +```python +import requests +url = "http://localhost:1337/v1/chat/completions" +body = { + "model": "gpt-3.5-turbo-16k", + "stream": False, + "messages": [ + {"role": "assistant", "content": "What can you do?"} + ] +} +json_response = requests.post(url, json=body).json().get('choices', []) + +for choice in json_response: + print(choice.get('message', {}).get('content', '')) +``` + + ## 🚀 Providers and Models ### GPT-4 |