strands-exaone for Python
Use the EXAONE Chat Completions API as a model provider for Strands Agents. This community-maintained package is not affiliated with LG AI Research or the Strands Agents project.
Review and follow the terms that apply to your use of the EXAONE API.
API key
Open the EXAONE API Platform, select Get an API Key, and sign in or create an EXAONE ID to follow the platform's key-issuance instructions. Each user supplies their own key. The illustrated setup guide shows the entry screens and includes Windows PowerShell instructions.
In the terminal where you will run your program, set the issued key:
export EXAONE_API_KEY='your-api-key'
Quick start
The Python distribution requires Python 3.10 or newer and strands-agents 1.63.x through 1.65.x. Install it from PyPI:
python -m pip install -U strands-exaone
from strands import Agent
from strands_exaone import ExaoneModel, ExaoneRetryStrategy
model = ExaoneModel(preserve_thinking=True)
agent = Agent(model=model, retry_strategy=ExaoneRetryStrategy(), callback_handler=None)
response = agent("Explain what an AI agent is in one sentence.")
print(response)
The provider reads EXAONE_API_KEY when the model is constructed. You can instead pass api_key=.... The package does not load .env files automatically.
The configured endpoint and any custom HTTP client receive your API key and conversation. Use a trusted endpoint and transport, and use HTTPS except for controlled local testing.
The callback handler determines whether intermediate reasoning and response text are printed. This example disables the default callback and prints only the final response; reasoning remains in conversation history for later turns.
For SDK tool use, streaming, structured output, Harness, and CLI walkthroughs, see the examples.
Why use this provider?
A standard OpenAI provider configured for EXAONE's endpoint can handle basic chat. ExaoneModel also carries EXAONE reasoning through conversation history and defaults to preserve_thinking=True. It maps model information, streaming, tools, usage, and API errors to Strands' interfaces. For tool arguments, it repairs a small set of syntax errors without changing values and rejects other malformed input.
For Agent and Harness calls, configure ExaoneRetryStrategy to honor server delay hints. The model's own HTTP retries are disabled by default. Other adapters may provide similar behavior through configuration or extensions; this package keeps the EXAONE mapping in one tested integration. See the project comparison for scope and trade-offs.
Configuration
| Option | Description | Default |
|---|---|---|
model_id |
EXAONE model ID. | k-exaone_v2.5 |
base_url |
API base URL, including /v1. Remote endpoints must use HTTPS; HTTP is allowed for loopback test servers. |
https://api.exaone.ai/v1 |
stream |
Request a streaming response; False adapts a non-streaming response to Strands events. |
True |
temperature, top_p |
Sampling parameters. | 1.0, 0.95 |
max_tokens, top_k, presence_penalty |
Generation parameters. | Service defaults when omitted |
reasoning_effort |
EXAONE reasoning setting. | Service default |
preserve_thinking |
Ask EXAONE to preserve previous reasoning in model input. | True |
enable_thinking |
Reasoning-generation option for compatible custom models. K-EXAONE 2.5 always reasons. | Service default |
include_usage |
Set stream_options.include_usage on streaming requests. |
True |
response_format |
Response format for ordinary agent calls. | Omitted |
timeout |
Deadline for sending the request, retry waits, reading the response, asynchronous metadata callbacks, and time the caller pauses between yielded stream events. A custom transport that stalls during cleanup can finish after the deadline. | No provider-imposed timeout |
context_window_limit |
Context window reported to Strands. Set a positive token count. | 524288 |
max_retries, base_retry_delay, max_retry_delay |
Optional retry policy. | 0 retries; 1 and 30 seconds |
metadata_callback |
Callback for successful request metadata. | None |
http_client |
Caller-owned httpx.AsyncClient for custom transport or headers. |
Provider-managed client |
params |
Additional Chat Completions parameters. | None |
Explicit options take precedence over matching params values, which take precedence over provider defaults. The provider manages model, messages, stream, tools, and tool_choice; do not set them in params. For streaming requests, params["stream_options"] can set include_usage and other service-supported options; the named include_usage option takes precedence. stream_options is omitted from non-streaming requests. params["response_format"] can set a format for ordinary model calls; the provider's response_format option takes precedence. Strands represents one completion, so n must be 1. Supported generation settings can vary by service version; see the EXAONE API documentation.
model_info.limits.context_window, when set, takes precedence over context_window_limit, following the Strands SDK's model info merge contract.
First-class generation options are validated before storage or a request. Values supplied through params remain an extension point and are passed through unless the provider owns the field; EXAONE may reject unsupported values.
update_config(...) applies to requests that have not started. Each in-flight request keeps the configuration it started with, including its retry policy.
Model information
ExaoneModel.model_info exposes the known k-exaone_v2.5 capabilities through Strands' standard ModelInfo: stateless Chat Completions, forced tool choice, and native JSON Schema output. The default context window is 524,288 tokens. An independent maximum output size and a prompt-caching mechanism are left unknown.
The SDK owns how these facts are used. Explicit model_info fields override the provider's defaults; unspecified fields inherit. model_info.limits.context_window takes precedence over context_window_limit. Capability defaults apply only to the exact known model ID. For another model ID, configure its actual limits and capabilities; the configured context_window_limit remains in effect.
The context budget covers input plus output, including reasoning. See the EXAONE API specification and Strands model-info contract.
Reasoning and tools
The provider stores reasoning separately from the final answer and sends it back as reasoning_content when it appears in the Strands conversation. By default, requests use EXAONE's recommended agent settings: temperature=1.0, top_p=0.95, and preserve_thinking=True. K-EXAONE 2.5 always reasons; enable_thinking can be forwarded for compatible custom models.
Strands can summarize older conversation history during automatic context management. The provider forwards the reasoning that remains in the history it receives; it cannot restore content that was summarized or removed. Token counts used for proactive context management are estimates, not exact EXAONE token counts.
Long-running agents should monitor memory and trace growth; behavior depends on the SDK version and workload.
The provider requests streaming usage by default (include_usage=True) so Strands can use token counts for context management. EXAONE may omit usage, and downstream context management is controlled by the framework.
Check both the returned reasoning fields and visible content. The request setting alone does not guarantee that reasoning is absent from the content.
When EXAONE returns a refusal without non-whitespace ordinary response content, the provider exposes that refusal as a Strands text block and preserves any whitespace content. Strands has no separate refusal event; the refusal remains available in response metadata as well. System prompt blocks follow the Strands OpenAI adapter contract: text blocks are sent as separate messages and blocks without text, such as cache points, are omitted.
For direct structured_output() calls, a refusal without JSON raises ExaoneError; its sanitized body includes the refusal text. Strands tool execution uses the Chat Completions tool_calls field. Legacy function_call response fields are retained in metadata but do not trigger a Strands tool.
from strands import Agent, tool
from strands_exaone import ExaoneModel, ExaoneRetryStrategy
@tool
def get_number() -> int:
"""Return the example number."""
return 7
agent = Agent(
model=ExaoneModel(preserve_thinking=True),
tools=[get_number],
retry_strategy=ExaoneRetryStrategy(),
callback_handler=None,
)
print(agent("Use the tool to get the number, then add 3."))
The provider assembles streamed tool-call arguments before exposing calls to Strands. If a completed tool call contains a JSON object with only closing braces or brackets missing, or a trailing comma, the provider completes that syntax without changing argument values. It rejects unterminated strings, missing values, and other malformed arguments. The Harness still validates arguments against each tool's schema. The provider accepts text, reasoning, tool calls, and text/JSON tool results. Unsupported content types and reasoning signatures present in the history received by the provider are rejected.
Because Chat Completions tool messages have no separate status field, tool results marked as errors are sent with an [ERROR] prefix. Successful results are sent without a prefix.
When Strands supplies multiple system text blocks, the provider sends them as separate system messages.
A user message containing both text and tool results is split into tool messages followed by a user text message, matching Strands' OpenAI Chat Completions adapter so tool responses remain adjacent to their assistant tool calls.
When using Strands Harness, configure its read tool to return a text description for image and document files:
from strands_harness import create_harness
from strands_exaone import ExaoneRetryStrategy
agent = create_harness(
model=ExaoneModel(),
retry_strategy=ExaoneRetryStrategy(),
builtin_tools={"*": False, "read": {"media": False}},
builtin_plugins=[],
session=False,
memory=False,
skills=False,
caching=False,
)
This setting keeps unsupported media blocks out of requests. It does not give the model image or document understanding. The read tool can access files allowed by the agent's sandbox, and it sends the results to the model endpoint. Use an isolated sandbox or an approval mechanism to limit access to files you intend to share.
Tools that use their own network transport may have TLS trust settings separate from the EXAONE provider's client.
Before repeating an interrupted task that may have side effects, inspect the external state.
Give concurrent agents separate session IDs, or serialize access to shared file sessions.
Cancellation may leave work running. Set suitable tool timeouts and check for external effects before retrying.
For side-effecting tools, make sure cancellation also invalidates any pending approval.
Configure callbacks for child agents and the parent when generated reasoning or tool output must not be printed.
The provider forwards text without trimming leading or trailing whitespace. During a tool turn, Strands may remove a block that contains only whitespace, so those blocks may not round-trip exactly.
Structured output
from pydantic import BaseModel
from strands import Agent
from strands_exaone import ExaoneModel
class Answer(BaseModel):
city: str
temperature_c: int
agent = Agent(model=ExaoneModel(), callback_handler=None)
result = agent("Return Seoul and a temperature of 20 degrees Celsius.", structured_output_model=Answer)
answer = result.structured_output
print(answer.city, answer.temperature_c)
In Strands SDK 1.64, structured_output_model uses the SDK's structured-output tool and may require additional model calls. A configured response_format is also sent on those tool-based calls; EXAONE's support for combining them has not been verified. The provider's direct async model.structured_output(...) method instead requests its own JSON Schema without streaming and validates the result against the Pydantic model. For ordinary model calls, response_format={"type": "json_object"} requests JSON object mode.
When using recursive schemas, verify that the selected framework path preserves schema references and that EXAONE supports the schema.
Structured-output calls reject aborted responses rather than treating them as valid schema results.
Handle validation failures through Strands' structured-output contract; the provider does not automatically rewrite prompts or retry model-generated output.
Retries
ExaoneModel's own HTTP retry loop is disabled by default. For Agent and Harness use, configure ExaoneRetryStrategy as the Strands retry strategy; it replaces the SDK default and honors EXAONE's Retry-After and Retry-After-Ms headers. It defaults to three total attempts, a one-second initial backoff, and a 30-second delay cap. If a server hint exceeds the cap, it surfaces the error instead of retrying early. Without a usable hint, it uses bounded exponential backoff with jitter.
Strands owns Agent-level retry selection, so a model provider cannot silently replace the SDK's strategy. ExaoneRetryStrategy is opt-in: pass an instance to Agent or create_harness to replace the generic policy with EXAONE-aware waits. The quick start and Harness example show this explicit configuration.
Strands' default retry strategy does not inspect EXAONE headers. Keeping it alongside the provider's own retry loop can multiply attempts, so leave max_retries at its default of zero when using ExaoneRetryStrategy. The strategy retries EXAONE transient HTTP errors, safe connection failures, and Strands throttling failures before the provider exposes output. It does not retry tool arguments that remain invalid after syntax-only completion or other model response errors.
To extend or narrow retryable errors, subclass ExaoneRetryStrategy and override Strands' is_retryable() method. Call super().is_retryable(error) to retain the EXAONE defaults. The strategy does not retry a provider failure after a stream event has been exposed, even if an override marks the error as retryable.
Unlike the SDK's default Python retry strategy, ExaoneRetryStrategy does not emit event_loop_throttled_delay. The current SDK exposes no public extension point for emitting this legacy event from a custom hook; supporting it while honoring server delay hints requires an upstream SDK extension.
ExaoneModel's optional max_retries setting remains available for direct model calls that do not use an Agent retry strategy. It retries connection failures before a response and retryable HTTP responses. The provider never replays a partially delivered stream. timeout bounds request work, provider retry waits, response reads, asynchronous metadata callbacks, and time the consumer pauses between yielded stream events. Agent-level ExaoneRetryStrategy waits are outside the model timeout. It cannot interrupt a synchronous callback while that function is running; an uncooperative custom transport can also delay response cleanup beyond the deadline. A caller-owned http_client retains its own transport timeouts.
When stopping iteration early, explicitly close the async generator so its response can be released promptly. This applies to both model.stream(...) and agent.stream_async(...):
from contextlib import aclosing
from strands_exaone import ExaoneModel
async def first_event():
model = ExaoneModel()
messages = [{"role": "user", "content": [{"text": "Hello"}]}]
async with aclosing(model.stream(messages)) as stream:
return await anext(stream)
Alternatively, signal cancellation and wait for the stream to finish closing.
Model routers can behave differently from provider retries when they switch after streaming begins. Test the framework's fallback behavior when partial output matters to your application.
For direct model calls, this configuration disables the Agent retry strategy and permits one provider retry with a maximum delay of 10 seconds:
from strands_harness import create_harness
from strands_exaone import ExaoneModel
agent = create_harness(
model=ExaoneModel(max_retries=1, max_retry_delay=10),
retry_strategy=None,
)
This option is intended for direct model calls or when choosing provider-level retries explicitly. For Harness use, ExaoneRetryStrategy is the recommended way to honor each EXAONE response's retry headers.
Metadata and errors
from strands_exaone import ExaoneModel
def on_metadata(metadata: dict) -> None:
print(metadata["request_id"], metadata["usage"])
model = ExaoneModel(include_usage=True, metadata_callback=on_metadata)
After a successful response, the callback receives status_code, request_id, selected response headers, usage, and response. Raw usage can include reasoning_tokens. Available response metadata includes top-level IDs, model, service and weight metadata, result_code, and description; choice-level finish_reason, matched_stop, and logprobs; and selected message fields. Streaming logprob and annotation arrays are accumulated in order; refusal fragments are joined, while audio and legacy function-call fragments remain in message_deltas. Fields are present only when supplied by the service. The callback is not called if the response fails or is interrupted before completion.
Asynchronous callbacks are awaited and receive task cancellation when the invocation's cancellation signal is set. When a signal is supplied, an asynchronous callback runs in a separate task; changes it makes to ContextVar values do not propagate back to the caller. A callback that suppresses cancellation may delay termination; a synchronous callback cannot be interrupted while it is running. Callback errors propagate to the caller. A callback's Strands throttling or context-overflow exception is wrapped in ExaoneError, with the original as its cause, so it is not mistaken for a model error after the response.
Strands usage metrics are emitted only when all three token counts are non-negative safe integers; raw usage remains available to the metadata callback even when those metrics cannot be emitted.
metrics.latencyMs is captured before the metadata callback runs. A streaming call still includes time the consumer spends paused between events, because the provider stream follows the caller's async iteration pace.
Metadata can contain user or generated content, including logprob tokens, refusal text, audio, and function arguments. It is not size-limited and can grow with the response. API keys are redacted, but metadata should only be logged or shared under an appropriate data policy. The provider does not copy ordinary assistant content, reasoning, or tool calls into response metadata.
ExaoneError exposes status_code, request_id, selected headers, sanitized body, and normalized error_type, code, and param fields. error_type and param come from the nested error object. code comes from error.code when that key is present, including when its value is null; otherwise it comes from the documented top-level result_code. Error messages use the sanitized error.message, then top-level description; HTTP failures fall back to HTTP {status}, while an error envelope in a successful response uses a generic provider message. ExaoneThrottledError subclasses Strands' ModelThrottledException, and ExaoneContextWindowError subclasses its ContextWindowOverflowException. Neither is a subclass of ExaoneError; each provides an ExaoneError in .details with the same diagnostics. Other API errors use ExaoneError. An injected http_client remains caller-owned.
HTTP 400 or 413 is classified as a context-window error only when error.code is exactly context_length_exceeded. Other errors, including messages that merely mention the context window, remain ExaoneError and do not trigger Strands' overflow recovery. Whether EXAONE returns this specific code for an actual overflow has not been verified.
Standard HTTPX transport and stream errors retain their exception type, with the API key redacted from the message. Custom HTTPX subclasses are forwarded as their nearest standard HTTPX base type. An HTTPStatusError raised by a custom client is forwarded as HTTPError with its status_code preserved, but without its original response. Forwarded HTTPX errors do not include the original request or chained transport errors.
Other exceptions raised by a custom HTTPX transport are passed through unchanged. Their messages and chained exceptions may contain sensitive data; configure custom transports and logging accordingly.
License
Metadata
Release files for strands-exaone 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strands_exaone-0.1.2.tar.gz | 250.7 kB | With provenance | Details for strands_exaone-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strands_exaone-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for strands_exaone-0.1.2-py3-none-any.whl |
Total release size: 281.6 kB
Release files / strands_exaone-0.1.2.tar.gz
| Download URL | strands_exaone-0.1.2.tar.gz |
|---|---|
| Size | 250.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2480964d5b37bae12427845951b127b640b1cc22a511db5b8d03799d3ebc8e25
|
|
BLAKE2b-256 checksum How to use checksums |
7ae38adeda5ebe24d8640286de5820be7e83a6ab09901d9177a3e5964d31981a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / strands_exaone-0.1.2-py3-none-any.whl
| Download URL | strands_exaone-0.1.2-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ef0258a53031364bf4cf10a561058ca75813101fbdd50cf97d69b749f773a1d
|
|
BLAKE2b-256 checksum How to use checksums |
6a9681a7244f712154c8e4023c2957a3feb7796f1fff496379cbddf3b6cb8a08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for strands-exaone 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for strands_exaone-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.