Spaces:
Sleeping
Sleeping
Download testapi.py from linhha2705/BackEnd: direct link, hf CLI and curl.
- Browser
- Download file 373 Bytes
-
https://huggingface.co/spaces/linhha2705/BackEnd/resolve/main/testapi.py
- Command line
-
hf download hf://spaces/linhha2705/BackEnd/testapi.py
-
curl -L -o testapi.py https://huggingface.co/spaces/linhha2705/BackEnd/resolve/main/testapi.py
373 Bytes
| from openai import OpenAI | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| OPENAI_API_KEY=os.getenv("OPENAI_API_KEY") | |
| client = OpenAI( | |
| api_key = OPENAI_API_KEY | |
| ) | |
| completion = client.chat.completions.create( | |
| model="gpt-4o-mini", | |
| store=True, | |
| messages=[ | |
| {"role": "user", "content": "What is the capital of Vietnam?"} | |
| ] | |
| ) | |
| print(completion.choices[0].message) |