|
```python |
|
|
|
import requests |
|
import json |
|
|
|
|
|
def get_crypto_market_analytics(): |
|
|
|
url = "https://api.openai.com/v1/engines/davinci/completions" |
|
|
|
|
|
api_key = "YOUR_OPENAI_API_KEY" |
|
|
|
|
|
prompt = "Generate AI Crypto markets analytics for Bitcoin, Ethereum, and other top cryptocurrencies." |
|
|
|
|
|
data = { |
|
"model": "davinci", |
|
"prompt": prompt, |
|
"max_tokens": 150 |
|
} |
|
|
|
|
|
headers = { |
|
"Content-Type": "application/json", |
|
"Authorization": f"Bearer {api_key}" |
|
} |
|
|
|
|
|
response = requests.post(url, headers=headers, data=json.dumps(data)) |
|
|
|
|
|
response_data = response.json() |
|
|
|
|
|
generated_text = response_data["choices"][0]["text"] |
|
|
|
return generated_text |
|
|
|
|
|
crypto_analytics = get_crypto_market_analytics() |
|
|
|
|
|
print(crypto_analytics) |