Documentation
API Reference
Playground

Overview

Getting startedModelsDeployment Options

Integrations

Hermes AgentClaude CodeCodex

Studio

Upstage Studio

Capabilities

Generate
API QuickstartReasoningStructured outputsTool callingFAQ
Parse
Extract
Embed

Deployment Options

Guides

Rate limitsContributor modeCounting tokensMCP serverRegional endpointsBeta services

Resources

CookbookPricingStatusChangelogError codesFAQ

Terms and Policies

Terms of UsePrivacy PolicyService level agreement

API Quickstart

For /v1/responses, see Using the Responses API. The other examples on this page use Chat Completions.

Make your first Solar API call, understand the response, and learn how to continue a conversation.

Before you begin

You need an Upstage account and API key. If you do not have them yet, follow Getting Started.

Install an OpenAI SDK

Solar is compatible with the OpenAI API. Before using the Solar API, install the official OpenAI SDK for your language.

pip install --upgrade openai

Make your first request

Start using the Solar API by sending a simple greeting.

Request

from openai import OpenAI

client = OpenAI(
    api_key="UPSTAGE_API_KEY",
    base_url="https://api.upstage.ai/v1"
)

response = client.chat.completions.create(
    model="solar-pro-4",
    messages=[
        {
            "role": "user",
            "content": "Hi, how are you?"
        }
    ]
)

print(response.choices[0].message.content)

Understand the response

The generated answer is in choices[0].message.content. Solar Pro 4 keeps reasoning off by default; set reasoning_effort to also receive the reasoning trace in the response—see Reasoning.

{
  "id": "f91f4bf3-d0c8-47f0-92cf-118933b7cb83",
  "object": "chat.completion",
  "created": 1785952699,
  "model": "solar-pro-4-260806",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hi! I'm doing well, thank you for asking. How are you doing today? Is there anything I can help you with?"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 57,
    "completion_tokens": 29,
    "total_tokens": 86,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  },
  "system_fingerprint": null
}
FieldDescription
choices[0].message.contentThe generated answer text.
choices[0].message.reasoningThe reasoning trace the model produced before answering.
choices[0].finish_reasonWhy generation stopped. stop means the model finished on its own.
modelThe exact model version that handled the request.
usage.prompt_tokensNumber of tokens in the request.
usage.completion_tokensNumber of tokens in the generated answer, including reasoning tokens.
usage.completion_tokens_details.reasoning_tokensNumber of tokens spent on reasoning.
usage.total_tokensSum of prompt and completion tokens.

For the complete response schema, see the Chat Completions API reference.

What models does Upstage provide?

The table below describes the models currently available as an API. Upstage provides stable aliases that point to specific model versions. These aliases let you integrate once and automatically benefit from future updates without needing to modify your code whenever a model is improved or replaced.

We recommend using aliases instead of hardcoding specific model names, as models are frequently updated. However, please note that model behavior may change slightly when an alias is updated—for example, in how prompts are handled or how outputs are structured. While we strive to ensure smooth transitions, we recommend validating key prompts and responses when using aliases in production.

solar-pro4 and solar-mini4, along with their snapshots solar-pro4-260806 and solar-mini4-260922, are the previous names of solar-pro-4 and solar-mini-4. They continue to work, so existing integrations need no changes.

AliasCurrently points toRPM / TPM (Learn more)
solar-pro-4 solar-pro-4-260806100 / 250,000
solar-pro-4-contributor solar-pro-4-260806-contributor100 / 250,000
solar-mini-4 solar-mini-4-260922100 / 250,000
solar-mini-4-5-preview solar-mini-4-5-preview100 / 250,000
syn-prosyn-pro-251021100 / 50,000

Continue the conversation

Chat Completions is stateless: it does not store your conversation history. Each request is handled on its own, so the model only knows what you send in messages.

To keep context across turns, resend the previous user and assistant messages together with the new user message.

Every resent message counts toward your input tokens, so a long conversation costs more with each turn. As the conversation approaches the model's context limit, trim or summarize older turns.

from openai import OpenAI

client = OpenAI(
    api_key="UPSTAGE_API_KEY",
    base_url="https://api.upstage.ai/v1"
)

messages = [
    {"role": "user", "content": "My favorite color is green."}
]

# First turn
first = client.chat.completions.create(
    model="solar-pro-4",
    messages=messages
)
messages.append({"role": "assistant", "content": first.choices[0].message.content})

# Second turn: the model answers from the history you send
messages.append({"role": "user", "content": "What is my favorite color?"})
second = client.chat.completions.create(
    model="solar-pro-4",
    messages=messages
)
print(second.choices[0].message.content)

# Append the response again to keep the conversation going
messages.append({"role": "assistant", "content": second.choices[0].message.content})

Stream the response

Streaming lets your application display text as it is generated, instead of waiting for the complete response. Each chunk carries a piece of the answer, so the first words appear within a moment.

from openai import OpenAI

client = OpenAI(
    api_key="UPSTAGE_API_KEY",
    base_url="https://api.upstage.ai/v1"
)

stream = client.chat.completions.create(
    model="solar-pro-4",
    messages=[
        {
            "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="", flush=True)

With the OpenAI SDK, each chunk exposes its text at choices[0].delta.content. When reasoning is on via reasoning_effort, the reasoning trace streams first in choices[0].delta.reasoning, before the answer chunks arrive. LangChain and LlamaIndex use their own chunk interfaces, as shown above. Raw SSE streams, including the cURL example, finish with data: [DONE].

Using the Responses API

The Responses API is available on Solar Pro 4, Solar Mini 4, and Solar Mini 4.5 Preview.

This API stores nothing, so a conversation is continued by sending the whole history. Append the previous response's output items to your input, then add the new user message. previous_response_id and conversation are rejected with a 400.

reasoning items may appear in output. Sending them back is safe — they are ignored, and reasoning is re-derived on each turn.

from openai import OpenAI

client = OpenAI(
    api_key="UPSTAGE_API_KEY",
    base_url="https://api.upstage.ai/v1",
)

first = client.responses.create(
    model="solar-pro-4",
    input="My name is Alex. Reply with ok.",
)

history = [{"role": "user", "content": "My name is Alex. Reply with ok."}]
history += [item.model_dump(exclude_none=True) for item in first.output]
history.append({"role": "user", "content": "What is my name?"})

second = client.responses.create(model="solar-pro-4", input=history)
print(second.output_text)  # Alex

Next steps

Now that your first request works, explore the capabilities you can build on top of it.

Reasoning

Let the model think through multi-step problems before answering.

Structured Outputs

Constrain responses to a JSON schema your application can parse.

Tool Calling

Let the model call your own tools and APIs.

Overview

Overview of building with Solar on Upstage — make your first API call, choose a model, add reasoning, structured outputs, and tool calling, then ship to production.

Reasoning

When to let Solar reason before answering, and how reasoning_effort trades extra tokens and latency for multi-step accuracy.

On this page

API QuickstartBefore you beginInstall an OpenAI SDKMake your first requestUnderstand the responseWhat models does Upstage provide?Continue the conversationStream the responseUsing the Responses APINext steps