# Chevet Subagent (Low-Cost High Frequency Agent) (`oscar.smith-owner/chevet-subagent`) Actor

AI subagent with OpenAI-compatible chat completions. ChevetAI Qwen is primary with OpenRouter DeepSeek fallback. Successful runs use low-cost PPE pricing; tools, including deep research, are included. Failed or incomplete runs publish no success output.

- **URL**: https://apify.com/oscar.smith-owner/chevet-subagent.md
- **Developed by:** [Oscar Smith](https://apify.com/oscar.smith-owner) (community)
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 completed requests

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Chevet Subagent Actor (`chevet-subagent`)

A low-cost, ultra-resilient LLM subagent actor designed for agent-to-agent MCP calling and autonomous workflows.

### Features

- **OpenAI-Compatible Chat Completions**: Accepts standard OpenAI `messages` array, `temperature`, `max_tokens`, `response_format`, etc.
- **Dual-Provider Architecture**:
  - **Primary**: Chevet AI Qwen 3.5 9B (`qwen3.5:9b`), high speed and cost efficiency.
  - **Secondary / Fallback**: OpenRouter DeepSeek Flash (`deepseek/deepseek-v4-flash-0731`), resilient fallback on provider outage or rate limiting.
- **Fail-closed usage pricing**: A completed response costs $0.0025 on Free, $0.0023 on Starter, $0.0022 on Scale, or $0.0020 on Business; each started 5,000 generated-token block costs $0.0009. All tools are included in the normal tool allowance. No PPE event is charged when required AI/tool work, output validation, or full charge preflight fails.
- **MCP-Ready**: Can be called directly via Apify's MCP tools by parent agents (Cursor, Claude Desktop, Antigravity, AutoGen, CrewAI, etc.).
- **Bounded Tooling**: Optional web, data, document, calculation, restricted-WASM Python, and per-run workspace-file tools. Python has no shell, network, package installation, host filesystem, or environment-variable access.

### Input Specification

| Field | Type | Required | Description |
|---|---|---|---|
| `messages` | `ChatMessage[]` | Optional\* | OpenAI-compatible messages: `[{ role: 'user', content: '...' }]` |
| `prompt` | `string` | Optional\* | Single prompt string (used if `messages` is omitted). |
| `system_prompt` | `string` | No | System message to set persona/instructions. |
| `enable_tools` | `boolean` | No | Enables the documented bounded tools for this run (default `false`). |
| `tool_profile` | `string` | No | `full` (default) preserves every existing tool. Choose `research`, `data`, `web_api`, or `workspace` to send and permit only the focused tool set. |
| `temperature` | `number` | No | Sampling temperature (default `0.7`). |
| `max_tokens` | `integer` | No | Per-turn maximum generated tokens (default `16,000`, maximum `16,384`). It is an allowance, not a guaranteed output length; unused tokens are not generated or billed. |
| `max_total_output_tokens` | `integer` | No | Aggregate generated-token ceiling across all model calls, 1–64,000 (default `64,000`). The actor fails without PPE charging if this is reached before completion. |
| `max_tool_uses` | `integer` | No | Total tool-use limit, 0–4 (default `4`), including restricted Python. |
| `top_p` | `number` | No | Nucleus sampling probability (default `1.0`). |
| `json_mode` | `boolean` | No | Enforces JSON output (default `false`). |
| `response_format` | `object` | No | OpenAI format, e.g. `{"type": "json_object"}`. |
| `model` | `string` | No | Optional model override. |
| `debug` | `boolean` | No | Output telemetry including latency and fallback tracking. |

*\* Either `messages` or `prompt` must be provided.*

### Pricing and limits

The `completed-request` event includes up to 24,000 initial input-context tokens and costs $0.0025 on Free, $0.0023 on Starter, $0.0022 on Scale, or $0.0020 on Business. Across a tool run, provider-reported input is guarded at 40,000 aggregate tokens. Input/prefill tokens are not separately billed. The actor totals only provider-reported `completion_tokens` across every model turn; reasoning-token telemetry is never billed separately. It charges $0.0009 for each started 5,000-token output block: 0 output tokens adds $0, 1–5,000 adds $0.0009, and 5,001–10,000 adds $0.0018. Normal tools and bridge orchestration have no separate PPE price; downstream Apify runs use the customer's configured Apify spend cap.

For example, a Free-tier completed request with 7,200 generated tokens costs $0.0025 + $0.0018 = $0.0043. The run preflights the complete event total against the user's Apify maximum using Apify's effective price for that run, then charges only after a valid final response exists. A failed provider path, aggregate input/output limit, or incomplete charge prevents publication of a success output.

The 64,000-token aggregate budget is spread over multiple calls. The default per-turn allowance is 16,000 tokens, so a normal response can use the full first three 5,000-token billing blocks when needed. It does not make every response 16,000 tokens long: providers report and bill only the tokens actually generated. Before every request, the runner dynamically reserves prompt and tool-schema space inside Qwen's 32,000-token context window. If a model reaches that shaped per-turn limit before finishing, the actor fails without publishing a paid success.

#### Restricted Python tool

When tools are enabled, the agent may call `run_python` for bounded computation, data transformation, and code tests. Python runs in a fresh WebAssembly worker with a 30-second maximum deadline and a memory limit. It accepts a restricted Python subset: no packages, shell commands, network, JavaScript interop, environment access, subprocesses, native filesystem access, or private-object introspection. Only `math` may be imported. Use `assert` statements for tests and `print()` for results. `read_text(path)` / `write_text(path, content)` and text-only `open(path, 'r'|'w'|'a')` only access the run workspace.

#### Tool profiles and bounded web retrieval

`full` keeps the complete tool surface for backwards compatibility. Focused profiles reduce prompt overhead and deny tools outside the selected set: `research` offers web research, PDFs, time, calculation, and workspace reading; `data` offers workspace/data processing and restricted Python; `web_api` offers safe HTTP and web retrieval; `workspace` offers file, search, structured-data, calculation, and restricted Python tools.

There is no deep-research meta-tool. The agent has a hard maximum of four total tool calls, so it must select sources deliberately. `fetch_web_page` returns a single clean excerpt of at most 3,000 characters, does not support offsets or pagination, and tool observations are compacted again before entering model history. This prevents a sequence of webpage calls from importing whole sites into the context window.

#### Example Input: Standard Chat

```json
{
  "messages": [
    { "role": "system", "content": "You are a concise research subagent." },
    { "role": "user", "content": "Summarize the 3 key advantages of event-driven architectures." }
  ],
  "temperature": 0.3,
  "max_tokens": 500,
  "enable_tools": false
}
```

#### Example Input: Fast Single Prompt

```json
{
  "prompt": "Classify this feedback as positive, neutral, or negative: 'The onboarding was fast but documentation lacks examples.'",
  "json_mode": true
}
```

### Output Specification

The actor returns standard OpenAI-compatible completion objects to both the **Dataset** and Key-Value Store (`OUTPUT` record):

```json
{
  "id": "chatcmpl-m7x9...",
  "object": "chat.completion",
  "created": 1725622400,
  "model": "qwen3.5:9b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 128,
    "total_tokens": 170
  },
  "provider_used": "chevet",
  "model_used": "qwen3.5:9b",
  "latency_ms": 384,
  "tools_enabled": false,
  "billing_summary": {
    "completed_request_count": 1,
    "llm_output_5k_count": 1,
    "total_completion_tokens": 128,
    "charges_completed": true
  }
}
```

### Environment Variables

- `CHEVET_API_KEY`: API key for Chevet AI.
- `CHEVET_BASE_URL`: Base URL for Chevet AI (default: `https://api.chevetai.com/v1`).
- `CHEVET_MODEL`: Primary model ID (default: `qwen3.5:9b`).
- `OPENROUTER_API_KEY`: API key for OpenRouter backup.
- `OPENROUTER_BASE_URL`: Base URL for OpenRouter (default: `https://openrouter.ai/api/v1`).
- `OPENROUTER_MODEL`: Backup model ID (default: `deepseek/deepseek-v4-flash-0731`).
- `STANDBY_API_KEY`: Required bearer key for the optional Apify Standby HTTP API. Normal batch runs never use it.

# Actor input Schema

## `messages` (type: `array`):

Array of message objects in standard OpenAI format: \[{ role: 'system'|'user'|'assistant', content: '...' }].

## `prompt` (type: `string`):

Convenience input if messages array is omitted. Converted automatically to a user message. A short, no-tools example is prefilled so the Actor can be tried immediately.

## `system_prompt` (type: `string`):

Optional instructions to set the subagent persona, goal, or context.

## `enable_tools` (type: `boolean`):

If enabled, tools are permitted for this sub-agent execution. If disabled, executes raw LLM inference only.

## `tool_profile` (type: `string`):

Optional focused tool set. Full preserves all existing tools; focused profiles reduce prompt overhead and restrict unavailable tools.

## `enable_thinking` (type: `boolean`):

If enabled, generates chain-of-thought thinking and returns the full reasoning trace alongside the normal output.

## `temperature` (type: `number`):

Sampling temperature between 0.0 and 2.0. Lower values are more deterministic.

## `max_tokens` (type: `integer`):

Maximum tokens to generate per model turn. Defaults to 16,000; the runner dynamically reserves prompt/tool context so no Qwen request exceeds its 32,000-token window.

## `max_total_output_tokens` (type: `integer`):

Aggregate generated-token allowance across all model turns. Maximum 64,000; each individual request remains context-bounded.

## `max_tool_uses` (type: `integer`):

Maximum tool calls across the entire request (0–4). Tool results are context-bounded; web retrieval returns excerpts, never whole pages.

## `top_p` (type: `number`):

Nucleus sampling probability.

## `json_mode` (type: `boolean`):

Guarantees the model returns a valid JSON object (sets response\_format: { type: 'json\_object' }).

## `response_format` (type: `object`):

Optional OpenAI response format specification (e.g., { 'type': 'json\_object' }).

## `model` (type: `string`):

Optional override for the model identifier.

## `apify_token` (type: `string`):

Your personal Apify API token (starts with 'apify\_api\_...'). Required only if you want the subagent to use the Apify Actor Bridge to spawn specialized scrapers under your account.

## `apify_actor_access_mode` (type: `string`):

Required with an Apify token: allow only listed actors, or block listed actors.

## `apify_actor_ids` (type: `array`):

Required with an Apify token. Exact actor IDs or supported aliases governed by the selected access mode.

## `apify_max_total_charge_usd` (type: `number`):

Required with an Apify token. Hard aggregate cap allocated across approved downstream actor calls.

## `apify_max_calls` (type: `integer`):

Maximum actor runs the subagent may start. Defaults to 1; maximum 5.

## `debug` (type: `boolean`):

Attach latency, provider resolution, and execution telemetry to dataset record.

## Actor input object example

```json
{
  "prompt": "Reply with exactly: Chevet Subagent is ready.",
  "enable_tools": false,
  "tool_profile": "full",
  "enable_thinking": false,
  "temperature": 0.7,
  "max_tokens": 16000,
  "max_total_output_tokens": 64000,
  "max_tool_uses": 4,
  "top_p": 1,
  "json_mode": false,
  "apify_max_calls": 1,
  "debug": false
}
```

# Actor output Schema

## `results` (type: `string`):

The single successful response record, including the model response, usage, tool-execution summary, and billing summary. Never published for failed or incomplete runs.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "prompt": "Reply with exactly: Chevet Subagent is ready."
};

// Run the Actor and wait for it to finish
const run = await client.actor("oscar.smith-owner/chevet-subagent").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "prompt": "Reply with exactly: Chevet Subagent is ready." }

# Run the Actor and wait for it to finish
run = client.actor("oscar.smith-owner/chevet-subagent").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "prompt": "Reply with exactly: Chevet Subagent is ready."
}' |
apify call oscar.smith-owner/chevet-subagent --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,oscar.smith-owner/chevet-subagent"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Jv0KOe83aZy8bAJmH/builds/VUfahOPcxXmKyPt5a/openapi.json
