Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/content/docs/integrations/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ section: Integrations
group: "Models"
order: 50
label: Anthropic
updated: "2026-10-08"
updated: "2026-11-20"
---

Run Claude models through the Anthropic Messages API, or reach Claude on Google Cloud Vertex AI or Amazon Bedrock. 10xGraph manages all three backends with a single provider configuration, translating your graph code to Anthropic's API while handling defaults, sampling parameters, caching, and error recovery automatically.
Expand Down Expand Up @@ -205,30 +205,40 @@ Older Claude models still accept these parameters, so they are stripped per-mode

If your code passes sampling parameters and you see them silently dropped, switch to using `reasoning_config` with the `effort` parameter to control the model's reasoning depth, or use `temperature` on older models that accept it.

## Prompt caching
## Provider-specific settings

Prompt caching reduces costs and latency when your agent uses the same system prompt and tools repeatedly. Enable it with `anthropic_cache`:
Pass any Messages API setting to `Agent(...)` (or `ReactAgent(...)`) as a keyword argument, named exactly as the Anthropic SDK names it, for example `service_tier`, `inference_geo`, `metadata` or `cache_control`:

```python
agent = Agent(
model="claude-opus-5",
anthropic_cache=True, # Simple: ephemeral cache with default TTL
service_tier="auto",
metadata={"user_id": "u-123"},
)
```

10xGraph sends a setting only if the installed `anthropic` SDK defines it on the method being called. A name the SDK does not define is not sent, and a warning names the key and the provider. A new SDK parameter works after you upgrade the SDK, with no 10xGraph release. The check is by name only: if the SDK accepts the name but the API or model refuses the value, Anthropic returns its error as usual. See [`Agent` keyword arguments](/docs/reference/python/agent#provider-specific-settings).

## Prompt caching

Prompt caching is on by default. Each request carries a cache breakpoint on the last system block (or on the last tool when there is no system prompt), plus top-level automatic caching. The automatic marker caches the whole conversation so far and moves forward on every call, so a long thread keeps reusing its prefix.

Turn it off, or change the lifetime, with `anthropic_cache`:

```python
agent = Agent(model="claude-opus-5", anthropic_cache=False) # no caching

# Or with explicit settings
agent = Agent(
model="claude-opus-5",
anthropic_cache={"type": "ephemeral", "ttl": "1h"}, # 1 hour retention
anthropic_cache={"type": "ephemeral", "ttl": "1h"}, # 1 hour TTL for both markers
)
```

Caching works at the prefix level. 10xGraph renders requests in a stable order: `tools` → `system` → `messages`. The cache breakpoint is placed at the end of the stable prefix (the last tool definition when tools are present, otherwise the last system block), leaving per-request messages after it. This means your tools and system prompt are cached across requests, but each message is fresh.

Because caching is a prefix match, any byte change after the breakpoint invalidates cached tokens. The minimum cacheable prefix is roughly 1024 tokens; shorter prefixes cache silently with no effect.
Caching is a prefix match, so any change before the breakpoint invalidates the cache. The minimum cacheable length depends on the model; a shorter prefix is not cached and is not an error. A cache write costs more than normal input (1.25x for the 5 minute TTL) and a read costs much less, so a second call that reuses the prefix already pays off.

Cache hits are logged at `DEBUG` level by the `tenxgraph.agent` logger as `Cache hit: N cached tokens (Anthropic messages)`, read from `usage.cache_read_input_tokens`.
Check that it works through `usage.cache_read_input_tokens`. 10xGraph records it on `Message.usages.cache_read_input_tokens` and logs hits at `DEBUG` level on the `tenxgraph.agent` logger as `Cache hit: N cached tokens (Anthropic messages)`.

If you pass your own top-level `cache_control` keyword argument to the `Agent`, 10xGraph does not add its own breakpoints, so you can customize the caching strategy.
If you set `cache_control` yourself anywhere (a top-level keyword argument, on a system block, or on a tool), 10xGraph adds nothing and keeps yours. This gives you full control and avoids errors from mixing your breakpoints with automatic ones.

## Batch processing for high-volume work

Expand Down
21 changes: 10 additions & 11 deletions src/content/docs/integrations/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ section: Integrations
group: "Models"
order: 40
label: Google
updated: "2026-10-08"
updated: "2026-11-20"
---

Run Gemini models through Google GenAI. The same models and features work through two backends, so you choose based on your infrastructure: a single API key for quick development, or Google Cloud integration for enterprise security and compliance.
Expand Down Expand Up @@ -374,18 +374,17 @@ agent = Agent(

## `llm_kwargs` Reference

All unrecognised keyword arguments passed to `Agent(...)` land in `self.llm_kwargs` and
are stored there; for Google only the keys below reach `GenerateContentConfig`.
Pass any `GenerateContentConfig` setting to `Agent(...)` (or `ReactAgent(...)`) as a keyword
argument, named as the `google-genai` SDK names it. 10xGraph forwards a key only if it is a
field of `types.GenerateContentConfig` in the installed SDK. Any other key is not sent, and a
warning names the key and the provider. New config fields work after you upgrade the SDK, with
no 10xGraph release.

| kwarg | Type | Notes |
|---|---|---|
| `cached_content` | `str` | Name of an explicit Gemini cache (e.g. `"cachedContents/abc123"`). Mutually exclusive with `system_instruction` in the config, 10xGraph handles this automatically. |
| `temperature` | `float` | Sampling temperature. |
| `max_tokens` / `max_output_tokens` | `int` | Maximum output tokens. Both aliases are accepted. |

Other keyword arguments (such as `top_p` and `top_k`) are not forwarded to Gemini.
The check is by name only. If the field exists but the API or model refuses the value,
Gemini returns its error as usual.

---
| kwarg | Type | Notes |
|---

## Environment Variables

Expand Down
21 changes: 15 additions & 6 deletions src/content/docs/integrations/openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ section: Integrations
group: "Models"
order: 30
label: OpenAI
updated: "2026-10-08"
updated: "2026-11-20"
faq:
- question: "Which OpenAI models work with 10xGraph?"
answer: "Any model your OpenAI account can call, for example gpt-4o, gpt-4o-mini and o4-mini. Names starting with gpt-, o1-, o3- or o4- are detected as OpenAI automatically. See platform.openai.com for the current list."
- question: "How do I enable caching for OpenAI?"
answer: "Prompt caching is automatic on OpenAI. Cache hits are logged at DEBUG level. Pass prompt_cache_key for stable cross-request hits."
answer: "Prompt caching is automatic on OpenAI, so there is nothing to switch on. Cache hits are logged at DEBUG level. Pass prompt_cache_key to Agent for stable cross-request hits."
- question: "Do I need to change code to use the Responses API?"
answer: "No. The Responses API is the default for the Agent. With a base_url the default is Chat Completions. Pass api_style='chat' to use Chat Completions, or api_style='responses' to force the Responses API."
---
Expand Down Expand Up @@ -216,8 +216,8 @@ agent = Agent(
)
```

This is an OpenAI request-level parameter forwarded directly through `llm_kwargs`. It is
**not** in `CALL_EXCLUDED_KWARGS` so it reaches the API unchanged.
This is an OpenAI request-level parameter. 10xGraph forwards it because the installed
`openai` SDK defines it on the method being called.

### `prompt_cache_retention`

Expand Down Expand Up @@ -324,8 +324,17 @@ local servers unless the server explicitly implements them.

## `llm_kwargs` Reference

All unrecognised keyword arguments passed to `Agent(...)` land in `self.llm_kwargs` and
are forwarded to the underlying API call.
Pass any OpenAI request setting to `Agent(...)` (or `ReactAgent(...)`) as a keyword
argument, named as the `openai` SDK names it. Unrecognised keyword arguments land in
`self.llm_kwargs`. 10xGraph forwards a key only if the SDK method being called
(`responses.create` or `chat.completions.create`, and their `parse` variants) defines it.
Any other key is not sent, and a warning names the key and the provider. A new SDK
parameter works after you upgrade the SDK, with no 10xGraph release.

The check is by name only. If the SDK accepts the name but the API or model refuses the
value, or a name means something different on another provider (`service_tier`,
`metadata`), OpenAI returns its error as usual. Examples on the Responses API:
`prompt_cache_key`, `prompt_cache_retention`, `service_tier`.

| kwarg | Type | Applies to | Notes |
|---|---|---|---|
Expand Down
20 changes: 18 additions & 2 deletions src/content/docs/reference/python/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ section: Reference
group: "Python library"
order: 30
label: Agent
updated: "2026-10-29"
updated: "2026-11-20"
---

The `Agent` class is a graph node that calls an LLM through the native OpenAI, Google, or Anthropic SDK. It handles message conversion, tool calls, memory retrieval, skills, streaming, and retries for you. Add it to a `StateGraph` as a node, and the graph supplies state and routing.
Expand Down Expand Up @@ -68,7 +68,23 @@ def __init__(
| `output_schema` | `type[BaseModel] \| None` | `None` | Pydantic model that the final text output must conform to. Not allowed with `"image"`, `"video"`, or `"audio"` output. |
| `use_vertex_ai` | `bool` | `False` | (via kwargs) Google provider only. Route Gemini through Vertex AI instead of Gemini API. Defaults to true when `GOOGLE_GENAI_USE_VERTEXAI=true`. For Claude it selects the Vertex backend. |
| `base_url` | `str \| None` | `None` | (via kwargs) Base URL for OpenAI-compatible APIs (Ollama, vLLM, OpenRouter, DeepSeek, etc.). |
| `**kwargs` | any | none | Additional provider-specific parameters: `temperature`, `max_tokens`, `top_p`, `top_k`, `organization_id`, `project_id`, etc. |
| `**kwargs` | any | none | Provider-specific settings, named as the provider SDK names them (`temperature`, `max_tokens`, `top_p`, `top_k`, `service_tier`, `cache_control`, `seed`, ...). Forwarded only when the SDK being called defines them. See [Provider-specific settings](#provider-specific-settings). |

### Provider-specific settings

Keyword arguments that `Agent` does not read itself are kept in `llm_kwargs` and passed to the provider call. `ReactAgent(...)` forwards its extra keyword arguments to `Agent`. Name each one as the provider SDK does:

| Provider | Examples | Checked against |
|---|---|---|
| Anthropic | `cache_control`, `service_tier`, `inference_geo`, `metadata` | the parameters of `messages.create` / `messages.stream` |
| OpenAI (Responses API, the default) | `prompt_cache_key`, `prompt_cache_retention`, `service_tier` | the parameters of `responses.create` / `chat.completions.create` |
| Google | `seed`, `safety_settings`, `cached_content`, `top_k` | the fields of `types.GenerateContentConfig` |

10xGraph forwards a setting only if the SDK being called defines it. Otherwise it is not sent and a warning names the key and the provider. This means one agent can carry settings for several providers, which works when the model is picked at runtime or a fallback model switches provider. A parameter added in a newer SDK works after you upgrade the SDK, with no 10xGraph release.

The check is by name only. If the SDK accepts the name but the API or model refuses the value (a wrong value, a model without that feature, or a name two SDKs share with different meanings such as `metadata` or `service_tier`), the provider returns its error as usual.

Settings 10xGraph reads itself (`provider`, `api_style`, `base_url`, `use_vertex_ai`, `anthropic_cache`) are not forwarded. Anthropic prompt caching is on by default; `anthropic_cache=False` turns it off. See [Anthropic](/docs/integrations/anthropic#prompt-caching). OpenAI and Gemini cache on the provider side, with nothing to switch on.

### Returns

Expand Down
Loading