Example
Request
# pip install openai
from openai import OpenAI # openai == 1.2.0
client = OpenAI(
api_key="UPSTAGE_API_KEY",
base_url="https://api.upstage.ai/v1"
)
response = client.chat.completions.create(
model="groundedness-check",
messages=[
{
"role": "user",
"content": "Mauna Kea is an inactive volcano on the island of Hawaiʻi. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth."
},
{
"role": "assistant",
"content": "Mauna Kea is 5,207.3 meters tall."
}
]
)
print(response)Response
{
"id": "c43ecfa6-31a9-4884-a920-a5f44fb727df",
"object": "chat.completion",
"created": 1710338020,
"model": "groundedness-check-240502",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "notGrounded"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 132,
"completion_tokens": 3,
"total_tokens": 135
},
"system_fingerprint": ""
}