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?
The provider preserves EXAONE reasoning across Strands turns, maps model information, streaming, tools, usage and errors, and performs limited tool-argument syntax completion for hosted 2.5. Configure ExaoneRetryStrategy for Agent and Harness calls to honor server delay hints; the model's own HTTP retries are disabled by default.
Configuration
| Option | Description | Default |
|---|---|---|
model_id |
EXAONE model ID. | k-exaone_v2.5 |
base_url |
HTTP or HTTPS API base URL, including /v1. |
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 |
Override the context window reported to Strands. Set a positive token count. | 524288 for k-exaone_v2.5; otherwise resolved by the SDK |
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.
Self-hosted K-EXAONE 2.0
For an OpenAI-compatible local server, pass the model name exposed by its /v1/models endpoint:
from strands_exaone import ExaoneModel
model = ExaoneModel(
base_url="http://127.0.0.1:8000/v1",
api_key="EMPTY", # Use the server's configured credential, if any.
model_id="K-EXAONE-2.0-750B-A37B", # Use the server's actual model name.
)
The provider accepts both reasoning_content and reasoning in compatible server responses and sends preserved reasoning back as reasoning_content. Identical values are emitted once; conflicting nonempty values are rejected. The model card lists a 262,144-token context window, but a deployment can configure a lower limit. Use the limit exposed by your deployment. Server and model compatibility depend on the versions and serving options you use.
For serving instructions and parser settings, see the model card. Its examples use forked servers; vLLM 0.27.0 also includes K-EXAONE 2.0 model support. Verify the specific server version and configuration you deploy.
The SGLang qwen3_coder parser in the inspected model-card fork and upstream revision converts the text null to JSON null even for a string parameter. This can cause tool validation to fail; check your server's parser version.
Some servers accept reasoning_effort and may use it to select thinking on or off. Accepting the field does not establish that the model supports distinct reasoning-intensity levels; check the deployed server and model documentation.
The configured API key is sent to the selected endpoint; if omitted, it comes from EXAONE_API_KEY. For a server that does not require authentication, pass a placeholder such as api_key="EMPTY" rather than the hosted API key. HTTP does not encrypt credentials or conversation data; use HTTPS or a trusted transport. Protocol fixtures have been tested, but K-EXAONE 2.0 model inference has not been verified by this project.
Self-hosted EXAONE 4.5 image input
For an already-running compatible endpoint, set base_url, api_key and model_id as above, using the server's actual EXAONE 4.5 model name. Supply image bytes through a standard Strands user content block:
from pathlib import Path
from strands import Agent
from strands_exaone import ExaoneModel
model = ExaoneModel(base_url="http://127.0.0.1:8000/v1", api_key="EMPTY", model_id="EXAONE-4.5-33B")
agent = Agent(model=model)
response = agent(
[
{"text": "Describe this image."},
{"image": {"format": "png", "source": {"bytes": Path("image.png").read_bytes()}}},
]
)
The provider sends text and image blocks in their original order. Strands Python image locations such as S3 are not converted to URLs; supply bytes. Image tool results remain unsupported. The default hosted K-EXAONE 2.5 model is text-only.
The EXAONE 4.5 model card shows vLLM and an SGLang fork with qwen3 reasoning and hermes tool parsers. Select and configure these on the server, not in the provider. Image requests have been tested with synthetic protocol fixtures; actual EXAONE 4.5 model inference has not been verified.
Server-specific observations
These observations use synthetic inputs and isolated server code, not running servers or EXAONE 4.5 inference. The provider preserves image/text order in its request; server processing determines what reaches the model.
- vLLM 0.27.0: With the official 4.5 template and automatic content-format detection, default normalization moved an image before surrounding text.
--interleave-mm-stringspreserved the order in the isolated test. - SGLang image/tool history: With the model-card fork
6757c9fand 4.5 template570aa4b, a first user message containing an image followed by a tool call and result could omit earlier assistant reasoning from the rendered prompt. A prior string-valued user message changed the result. - SGLang streaming tools: With automatic tool choice, the same fork could emit a tool name without arguments when the complete synthetic call and stop arrived in one final event. Missing arguments can fail validation or invoke a tool with defaults. The parser condition also occurred in SGLang 0.5.23 in isolation; this does not establish 4.5 model support. See issue #31915 and proposed fix #32167.
The provider does not repair these server behaviors. Check your server version, template and settings; see the compatibility matrix for details.
Model information
ExaoneModel.model_info exposes the known k-exaone_v2.5 capabilities through Strands' standard ModelInfo: stateless Chat Completions, forced tool choice, native JSON Schema output, and a 524,288-token context window. 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. Provider defaults apply only to the known model ID at the hosted endpoint. For other endpoints or model IDs, the SDK's lookup or fallback applies unless you configure its actual limits and capabilities. Explicit limits remain in effect when changing models.
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.
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. For the hosted k-exaone_v2.5 endpoint only, it completes missing closing braces or brackets and removes trailing commas when that produces a JSON object. This cannot detect a truncated value: for example, 12 may have been intended as 123. The Harness validates the resulting object against the tool schema, but cannot determine the intended value. Other malformed arguments are rejected; self-hosted endpoints receive no such syntax completion. 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.
Cancellation may leave work running; for side-effecting tools, also invalidate pending approvals and check external state before retrying.
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.
To use provider-level retries with a Harness agent, disable the Agent retry strategy. This configuration 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.
When the endpoint reports cached or cache-write input tokens, the Strands usage event also exposes them as cacheReadInputTokens and cacheWriteInputTokens. These are input-token details; they are not added again to the input total.
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.3
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.3.tar.gz | 256.2 kB | With provenance | Details for strands_exaone-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strands_exaone-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for strands_exaone-0.1.3-py3-none-any.whl |
Total release size: 289.5 kB
Release files / strands_exaone-0.1.3.tar.gz
| Download URL | strands_exaone-0.1.3.tar.gz |
|---|---|
| Size | 256.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9acb1cce3e1145d7519d7e68ddf13da2b8a567f0fb78d14dc250b6592033aec3
|
|
BLAKE2b-256 checksum How to use checksums |
6f907caf5e6d6c7a97b4a75a905505bae15622e5b4b49966451dddabff77660c
|
| 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 16, 2026.
Transparency logRelease files / strands_exaone-0.1.3-py3-none-any.whl
| Download URL | strands_exaone-0.1.3-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a8aa68c10f2fde51cc16caa64a64ab1f52cd14357dc672e71a3674cf5b45377
|
|
BLAKE2b-256 checksum How to use checksums |
1eee2e4390e283ea246c7a63ae0b98027bb195dcd305c364230b047d4799819c
|
| 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 16, 2026.
Transparency logSecurity for strands-exaone 0.1.3
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.3.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 16, 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.