Here’s a simple example of how to make an API call using Python:
```python
import requests
def generate_chat_response(prompt):
headers = {'Content-Type': 'application/json', 'Authorization': f'Bearer {API_KEY}'}
data = {
'messages': [{'role': 'user', 'content': prompt}]
}
response = requests.post('
https://api.openai.com/v1/chat/completions', headers=headers, json=data)
return response.json()
['choices'][0]['message']['content']
'YOUR_API_KEY'` with your actual API key. This function sends a user prompt to ChatGPT and returns the generated response.