Create ask

Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL.

POST /v1/code/ask

Addresshttps://api.hanzo.ai/v1/code/ask
MethodPOST
Operationpost_code_ask
AuthAuthorization: Bearer $HANZO_API_KEY

Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL. query and repo in the body take precedence over ?q= and ?repo=; either source works alone.

Request

2 fields, body application/json (required).

FieldInTypeRequiredDescription
querybodystring—Query is the question, from the BODY.
repobodystring—Repo is the repository narrowing, from the BODY.

Response

StatusBodyMeaning
200code.AskAnswerok
defaultproblem-detailsrefused

200 body — 9 fields.

FieldInTypeAlwaysDescription
answerbodystring—Answer is the synthesized prose.
citationsbodycode.Citation[]—Citations are the exact regions the answer was grounded on, and they are the point: an answer is checkable only because every claim in it can be read back at a file and line.
citations[].endLinebodyinteger (int64)—EndLine is its last line, inclusive.
citations[].filebodystring—File is the path inside the repo, relative to its root.
citations[].linebodyinteger (int64)—Line is the first line of the cited region, 1-based.
citations[].repobodystring—Repo is the repository the cited code lives in ("owner/name"), absent when the ask was already scoped to one.
citations[].symbolbodystring—Symbol is the declaration the region belongs to, when it belongs to one.
degradedbodyboolean—Degraded is true when retrieval worked but no synthesizer was reachable.
questionbodystring—Question is the ask, echoed back.

Failure carries the platform error shape — see Errors.

Examples

hanzo code ask create
import { Configuration, CodeApi } from 'hanzoai';

const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postCodeAsk({ query: "<query>", repo: "<repo>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CodeApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CodeApi(client).post_code_ask(query="<query>", repo="<repo>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.CodeAPI.PostCodeAsk(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, code_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = code_api::post_code_ask(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new CodeApi(client).postCodeAsk();
curl -X POST https://api.hanzo.ai/v1/code/ask \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "query": "<query>",
       "repo": "<repo>"
     }'

MCP reaches code through the code tool, which names its 7 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_code_ask"
         }
       }
     }'

Code API · All Hanzo APIs · Interactive reference

Was this page useful?