API reference
Structure drawings
2D structure and reaction drawings (SVG) from SMILES and reaction SMILES, drawn on CogniChem servers. Free; structures are not sent to other services.
On this page
Draw 2D structures from SMILES
POST/api/v1/depict
API key or token
SVG drawings for up to 20 SMILES, in request order. A SMILES that cannot be drawn returns svg: null with an error code instead of failing the request. Structures are drawn on CogniChem servers and never sent to another service.
Request body
application/json · DepictRequest
| Field | Type | Description |
|---|---|---|
height | integer | Pixels. Default: |
smiles[]required | string[] | Up to 20 SMILES (each 1-1000 characters). Limits: |
width | integer | Pixels. Default: |
Example request
curl -X POST "https://api.cognichem.com/api/v1/depict" \
-H "X-Api-Key: $COGNICHEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"height": 220,
"smiles": [
"CC(=O)Oc1ccccc1C(=O)O"
],
"width": 300
}'import os
import httpx
response = httpx.post(
"https://api.cognichem.com/api/v1/depict",
headers={"X-Api-Key": os.environ["COGNICHEM_API_KEY"]},
json={
"height": 220,
"smiles": ["CC(=O)Oc1ccccc1C(=O)O"],
"width": 300,
},
)
response.raise_for_status()
print(response.json())Uses httpx; the Python SDK has no method for this endpoint.
Responses
Successful Response · application/json · DepictResponse
| Field | Type | Description |
|---|---|---|
items[]required | Depiction[] | |
items.error | string | null | unparseable: not valid SMILES (or reaction SMILES). too_large: more than 200 heavy atoms (in the whole reaction). render_failed: the structure could not be laid out. One of: |
items.svg | string | null | SVG document with a transparent background. |
{
"items": [
{
"svg": "<?xml version='1.0' encoding='iso-8859-1'?>\n<svg version='1.1' …</svg>"
},
{
"error": "unparseable"
}
]
}Errors are RFC 7807 problem details (application/problem+json) with status, title, detail, request_id, and a retryability hint (validation, auth, quota, conflict, upstream, timeout, or terminal). Handling errors
| Status | When |
|---|---|
400 | Invalid input or business rule violation. |
401 | Missing or invalid credentials. |
402 | Wallet cannot cover the Assistant turn hold. |
403 | Authenticated but not allowed to access the resource. |
404 | Resource not found or not owned by the user. |
409 | Conflict (e.g. idempotency key reuse with a different body). |
413 | Request body or workflow spec exceeds size caps. |
422 | Request body or query failed validation. |
429 | Rate limit exceeded. |
500 | Unexpected server error. |
503 | Dependency temporarily unavailable. |
Draw reactions from reaction SMILES
POST/api/v1/depict/reactions
API key or token
SVG drawings of up to 20 reactions (reactants, agents over the arrow, products), in request order; atom maps are drawn when present. A reaction that cannot be drawn returns svg: null with an error code. Drawn on CogniChem servers and never sent to another service.
Request body
application/json · DepictReactionsRequest
| Field | Type | Description |
|---|---|---|
height | integer | Pixels. Default: |
reactions[]required | string[] | Up to 20 reaction SMILES (each 3-2000 characters), optionally atom-mapped. CXSMILES extensions are refused. Limits: |
width | integer | Pixels. Default: |
Example request
curl -X POST "https://api.cognichem.com/api/v1/depict/reactions" \
-H "X-Api-Key: $COGNICHEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"height": 220,
"reactions": [
"CC(=O)O.OCC>>CC(=O)OCC.O"
],
"width": 600
}'import os
import httpx
response = httpx.post(
"https://api.cognichem.com/api/v1/depict/reactions",
headers={"X-Api-Key": os.environ["COGNICHEM_API_KEY"]},
json={
"height": 220,
"reactions": ["CC(=O)O.OCC>>CC(=O)OCC.O"],
"width": 600,
},
)
response.raise_for_status()
print(response.json())Uses httpx; the Python SDK has no method for this endpoint.
Responses
Successful Response · application/json · DepictResponse
| Field | Type | Description |
|---|---|---|
items[]required | Depiction[] | |
items.error | string | null | unparseable: not valid SMILES (or reaction SMILES). too_large: more than 200 heavy atoms (in the whole reaction). render_failed: the structure could not be laid out. One of: |
items.svg | string | null | SVG document with a transparent background. |
{
"items": [
{
"svg": "<?xml version='1.0' encoding='iso-8859-1'?>\n<svg version='1.1' …</svg>"
},
{
"error": "unparseable"
}
]
}Errors are RFC 7807 problem details (application/problem+json) with status, title, detail, request_id, and a retryability hint (validation, auth, quota, conflict, upstream, timeout, or terminal). Handling errors
| Status | When |
|---|---|
400 | Invalid input or business rule violation. |
401 | Missing or invalid credentials. |
402 | Wallet cannot cover the Assistant turn hold. |
403 | Authenticated but not allowed to access the resource. |
404 | Resource not found or not owned by the user. |
409 | Conflict (e.g. idempotency key reuse with a different body). |
413 | Request body or workflow spec exceeds size caps. |
422 | Request body or query failed validation. |
429 | Rate limit exceeded. |
500 | Unexpected server error. |
503 | Dependency temporarily unavailable. |