Spaces:
Running
Running
from openai import OpenAI | |
from dotenv import load_dotenv | |
import os | |
# Load the .env file and get the API key | |
load_dotenv() | |
api_key = os.getenv("OPENAI_API_KEY") | |
# Initialize OpenAI client with OpenAI's official base URL | |
client = OpenAI( | |
api_key=api_key, | |
base_url="https://api.openai.com/v1" | |
) | |
# Use a simple model like gpt-3.5-turbo | |
completion = client.chat.completions.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "user", "content": "what is the Jacobian matrix"} | |
] | |
) | |
# Print the response | |
print(completion.choices[0].message.content) |