Getting started
Quick start
Get an API key
To get an API key, just click Create new key
. You can view keys on the API keys page.
API key
To get an API key, just click Create new key
. You can view keys on the API keys page.
Choose the task and request the API with the example code.
from openai import OpenAI # openai==1.2.0
client = OpenAI(
api_key="UPSTAGE_API_KEY",
base_url="https://api.upstage.ai/v1/solar"
)
stream = client.chat.completions.create(
model="solar-pro",
messages=[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hi, how are you?"
}
],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")
# Use with stream=False
# print(stream.choices[0].message.content)