---
title: "Validate that imports/packages in LLM-generated code are real and not hallucinated."
method: POST
path: "/v1/validate/imports"
tags: ["core"]
---

# Validate that imports/packages in LLM-generated code are real and not hallucinated.

`POST /v1/validate/imports`

## Request

- Base URL: `https://api.agent-toolbox.ai`
- URL: `https://api.agent-toolbox.ai/v1/validate/imports`
- Auth: one of:
  - HTTP bearer
  - none

Cost: 1 credit(s). Free tier: 10 calls per IP (no auth).

## Request body

- ValidateImportsRequest
  - `language` 'python' | 'javascript' | 'typescript' | 'rust' | 'go', required
  - `code` string, required
  - `timeoutMs` integer

## Response `200`

Success.

- ValidateImportsResponse
  - `language` 'python' | 'javascript' | 'typescript' | 'rust' | 'go', required
  - `valid` object[], required
    - `name` string, required
    - `raw` string, required
    - `status` 'valid' | 'hallucinated' | 'unknown', required
    - `registry` string
    - `registryUrl` string
    - `error` string
  - `hallucinated` object[], required
    - `name` string, required
    - `raw` string, required
    - `status` 'valid' | 'hallucinated' | 'unknown', required
    - `registry` string
    - `registryUrl` string
    - `error` string
  - `unknown` object[], required
    - `name` string, required
    - `raw` string, required
    - `status` 'valid' | 'hallucinated' | 'unknown', required
    - `registry` string
    - `registryUrl` string
    - `error` string
  - `totalImports` integer, required
  - `hallucinationRate` number, required
  - `latencyMs` number, required: Server compute time in ms.

## Other responses

- `400`: Invalid request body.
- `402`: Free tier exhausted or insufficient credits.

---

[API](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api.md) · [All operations](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api/revisions/07132043190b?raw)
