File size: 703 Bytes
685d968 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import os
from dotenv import load_dotenv
import cohere
load_dotenv()
key = os.getenv("CO_API_KEY")
if key:
print(f"Key found. Length: {len(key)}")
print(f"Prefix: {key[:4]}...")
try:
client = cohere.ClientV2(api_key=key)
print("Client initialized.")
# Simple test call
print("Testing simple chat...")
response = client.chat(
model="command-r-plus", # Use a cheaper/standard model for quick test
messages=[{"role": "user", "content": "Hello"}]
)
print("Response received!")
print(response)
except Exception as e:
print(f"Error: {e}")
else:
print("Key NOT found in environment.")
|