---
title: "Generate Python strategy code from natural language"
method: POST
path: "/api/v1/generate"
tags: ["Strategy"]
---

# Generate Python strategy code from natural language

`POST /api/v1/generate`

## Request

- Base URL: `https://api.quantifyme.ai`
- URL: `https://api.quantifyme.ai/api/v1/generate`
- Auth: API key in header `X-API-Key`

## Request body

- GenerateRequest
  - `api_key` string: Your API key, if you cannot set the X-API-Key header. Agents that mint a key at runtime (e.g. a ChatGPT Action calling POST /api/v1/key/trial) should pass the returned `api_key` here on every subsequent call. The X-API-Key header wins when both are present.
  - `aux_feeds` object[]: Extra (symbol, timeframe) feeds merged into the strategy's features as aux_* columns. Max 3; must differ from the primary.
    - `symbol` 'EURUSD' | 'GBPUSD' | 'USDJPY' | 'USDCHF' | 'AUDUSD' | 'NZDUSD' | 'USDCAD' | 'BTCUSD'
    - `timeframe` '1min' | '5min' | '15min' | '1h'
  - `claude_model` 'sonnet' | 'opus' | 'haiku'
  - `description` string: Optional one-line natural-language summary; Claude treats it as PRIMARY USER REQUEST.
  - `end_date` string, date
  - `features` string
  - `indicators` Indicators: Flat indicator config. See GET /api/v1/indicator-schema for full param list.
  - `model` string
  - `optimization` string
  - `pos_rules` PosRules
    - `cooldown` integer
    - `direction` 'both' | 'long' | 'short'
    - `max_pos` integer
    - `on_opposite` 'reverse' | 'close_only' | 'ignore'
  - `risk` string
  - `risk_function` string
  - `signals` string
  - `start_date` string, date
  - `symbol` 'EURUSD' | 'GBPUSD' | 'USDJPY' | 'USDCHF' | 'AUDUSD' | 'NZDUSD' | 'USDCAD' | 'BTCUSD': Forex pair to train/backtest on.
  - `timeframe` '1min' | '5min' | '15min' | '1h': OHLC bar size.
  - `train_split` number

## Response `200`

Successful response

- GenerateResponse
  - `code` string: Full generated Python strategy code (feature_engineering + strategy_config functions).
  - `credits_remaining` integer

## Other responses

- `400`: Bad request
- `401`: Invalid or missing API key
- `429`: Rate limit exceeded, or insufficient credits (body carries credits_remaining and credits_required)

---

[API](https://skmtc.dev/quantifyme/apis/quantifyme-api.md) · [All operations](https://skmtc.dev/quantifyme/apis/quantifyme-api/llms.txt) · [OpenAPI document](https://skmtc.dev/quantifyme/apis/quantifyme-api/revisions/089d1cee1ec5?raw)
