Skip to content

Instantly share code, notes, and snippets.

@mberman84
Created December 15, 2023 16:03
Show Gist options
  • Select an option

  • Save mberman84/4f716ced4f2ebf4f1d7b37aba75446a7 to your computer and use it in GitHub Desktop.

Select an option

Save mberman84/4f716ced4f2ebf4f1d7b37aba75446a7 to your computer and use it in GitHub Desktop.
Mistral API Script
import requests
url = "https://api.mistral.ai/v1/chat/completions"
token = "API_KEY"
model = "mistral-medium"
prompt = """
John and Mark are in a room with a ball, a basket and a box. John puts the ball in the box, then leaves for work. While John is away, Mark puts the ball in the basket, and then leaves for school. They both come back together later in the day, and they do not know what happened in the room after each of them left the room. Where do they think the ball is?
"""
headers = {
'Authorization': f'Bearer {token}'
}
data = {
"model": model,
"messages": [{"role": "user", "content": prompt}]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
response_json = response.json()
content = response_json['choices'][0]['message']['content']
print(content)
else:
print(f"Error: Received status code {response.status_code}")
print(response.text)
@wd021
Copy link

wd021 commented Jul 10, 2025

bring your prompt 🧠 to God Tier Prompts! 🪄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment