Python API
The Python API provides compatibility for the OpenAI chat API standard, allowing easier integrations into existing python applications.
Requirements
Install the module needed.
python -m pip install requests
Example code
Simply replace the yourAPIkey
in your project.
import requests
url = "https://api.nmesh.io/api/v1/chat/completions"
payload = {
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct-Q8",
"messages": [
{
"role": "system",
"content": "You are an expert to chat with."
},
{
"role": "user",
"content": "tell me a joke"
}
],
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"Authorization": "Bearer yourAPIKey"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Updated 3 months ago
What’s Next