---
title: "Generates code based on the provided prompt."
method: POST
path: "/code/generate-code"
tags: ["code"]
---

# Generates code based on the provided prompt.

`POST /code/generate-code`

Events are streamed via WebSocket connection. This endpoint returns immediately
after starting the generation process.

## Request body

- GenerateCodeRequest
  - `assistantMessageId` string, uuid, nullable
  - `chatSessionId` string, uuid, required
  - `config` ChatSessionConfig — Configuration for chat session with system prompt and LLM key
    - `is_onboarding_session` boolean, required
    - `llm_key` 'vllm.gpt-5-mini-2025-08-07' | 'vllm.gpt-4.1-mini-2025-04-14' | 'vllm.gpt-5-nano-2025-08-07' | 'vllm.gpt-5-2025-08-07' | 'vllm.ft:gpt-4o-2024-08-06:structify::ADrF00Gq' | 'vllm.ft:gpt-4o-mini-2024-07-18:structify::ABCLHTsN' | 'vllm.action' | 'vllm.dora' | 'vllm.boring_dora' | 'vllm.claude-3-7-sonnet-20250219' | 'vllm.claude-sonnet-4-20250514' | 'vllm.qwen-3-coder-480b' | 'test_llm.test' | 'bedrock.claude-sonnet-4-bedrock' | 'bedrock.claude-sonnet-4-5-bedrock' | 'bedrock.claude-opus-4-5-bedrock' | 'bedrock.claude-haiku-4-5-bedrock' | 'gemini.gemini-2.5-pro' | 'gemini.gemini-2.5-flash' | 'gemini.gemini-3-pro-preview' | 'gemini.gemini-3-flash-preview' | 'vertex_anthropic.claude-sonnet-4-5-vertex' — LLM model keys available in the system. Format: <provider>.<model-name>
    - `max_steps` integer, nullable
    - `reminder_message` string, nullable
    - `system_prompt` string, nullable
  - `connectorIds` ConnectorId[]
  - `filePaths` string[]
  - `prompt` string, required
  - `triggerWorkflowExecution` boolean
  - `userMessageId` string, uuid, nullable

## Response `200`

Code generation started successfully

## Other responses

- `400` — Bad request
- `401` — Unauthorized - user is not authenticated
- `403` — Forbidden - user does not have write access to chat session
- `404` — Chat session not found
- `500` — Internal server error

## Changes

- **2026-01-29** `5c66830e8ae0` — 1 info
  - added the new `gemini.gemini-3-flash-preview` enum value to the request property `config/allOf[#/components/schemas/ChatSessionConfig]/llm_key/allOf[#/components/schemas/LLMKey]/`
- **2026-01-23** `58eb8eebcd42` — 2 info
  - added the new optional request property `connectorIds`
  - added the new optional request property `filePaths`
- **2026-01-22** `7ea3670b144a` — 1 info
  - added the new optional request property `config/allOf[#/components/schemas/ChatSessionConfig]/max_steps`
- **2026-01-15** `40d4421ab221` — 1 info
  - added the new `bedrock.claude-haiku-4-5-bedrock` enum value to the request property `config/allOf[#/components/schemas/ChatSessionConfig]/llm_key/allOf[#/components/schemas/LLMKey]/`

[Change history](https://skmtc.dev/structifyai/apis/structify/changes/code/generate-code/post.md)

---

[API](https://skmtc.dev/structifyai/apis/structify.md) · [All operations](https://skmtc.dev/structifyai/apis/structify/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/structifyai/structify/revisions/1364930b6980/schema)
