[Integrations](https://spiral.ai/integrations) › [opencode](https://spiral.ai/integrations/opencode) › [PubChem compound search](https://spiral.ai/integrations/opencode/pubchem-compound-search)

# How to Use PubChem compound search in opencode

Finds PubChem compound records matching a chemical name, identifier, structure, or molecular formula. Use it to resolve a chemical to a CID before retrieving its properties or research links.

|  |  |
| --- | --- |
| Model | PubChem compound search |
| Available through | Alexandria |
| Category | Health |
| Price | $0.00873 per call. |
| Returns | json |
| Runs | In the background |
| Setup | About 2 minutes, no API key |

## Prompts to try with PubChem compound search in opencode

- Use PubChem compound search to resolve aspirin, caffeine, and imatinib, then add the returned CIDs to the chemical examples in this project's data file.
- Use PubChem compound search to look this up and give me the result as a table. Save the result in ./assets.
- Pull the latest numbers from PubChem compound search and tell me what changed since last week.
- Check PubChem compound search and summarize what you find in three bullet points.
- Pull the newest data from PubChem compound search and give me the result as a table.

## How to set up PubChem compound search in opencode

Pick the way that suits you. Each takes about two minutes.

### Use Spiral's MCP server

1. **Add the server**: Leave out `--global` to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.

```bash
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
```

2. **Sign in**: Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, `/mcps` starts the same sign-in.

```bash
opencode mcp auth spiral
```

3. **Check it**: Spiral shows as connected.

```bash
opencode mcp list
```

### Use the Spiral skill

1. **Send opencode this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run PubChem compound search**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "alexandria",
    "model": "pubchem-ncbi-nlm-nih-gov/compounds/search",
    "input": {
      "query": "<query>"
    }
  }'
```

Then paste one of the prompts above: opencode finds PubChem compound search on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/opencode

## PubChem compound search tools and prices

- [PubChem: chemical compounds, bioassays, targets and patents · Search](https://spiral.ai/tools/alexandria/pubchem-ncbi-nlm-nih-gov/compounds/search) (Alexandria): $0.00873 per call.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| kind | auto, cid, name, smiles, inchikey, inchi, formula | auto | How to read query; auto guesses from its shape (a formula is Hill order with counts, "CO" reads as a formula, so set smiles for methanol written that way). |
| limit | 1 to 50 | 10 | Compounds per page. |
| offset | 0 to 100000 | 0 | Compounds to skip, from next_offset. |

## What can you do with PubChem compound search in opencode?

Build a compound research view in your project that connects chemical identities with properties and research evidence. Use PubChem CIDs to keep structural matches, assay results, targets, and patent links attached to the intended chemical.

### Prepare a compound research dossier

Resolve imatinib to its chemical record, collect its properties, summarize reported targets and assays, and assemble linked patent publications for reading.

### Triage structural analogues

Find structures resembling a seed compound, confirm their identities, and compare available properties, assay evidence, targets, and patent links before selecting candidates for closer study.

### Compare compound target profiles

Start from imatinib and structurally related compounds. Match identities and properties, organize their reported targets, and inspect the assay results behind shared or differing associations.

### Build a patent reading list around a structure

Confirm a seed compound, find related structures, and collect their linked patent publication identifiers. Organize documents for reading without treating chemical mentions as proof of claim coverage.

### Review a research watchlist each week

Repeat identity, property, structural-neighbor, assay, target, and patent queries for a fixed compound watchlist. Compare retrieved results with earlier snapshots to flag changes for a researcher.

### Annotate a public chemical dataset

Resolve chemical names to CIDs and attach computed properties, reported biological targets, assay references, and patent publication links to each identified structure.

### Teach chemical identity and structural similarity

Use aspirin and caffeine to demonstrate name resolution, computed properties, and structural searches. Show students why a molecular formula or fingerprint match does not establish complete structural identity.

## Overview

- [Alexandria](https://spiral.ai/providers/alexandria)
- [All opencode guides](https://spiral.ai/integrations/opencode)

## PubChem compound search in other agents

- [Amp](https://spiral.ai/integrations/amp/pubchem-compound-search)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/pubchem-compound-search)
- [Claude](https://spiral.ai/integrations/claude-desktop/pubchem-compound-search)
- [Claude Code](https://spiral.ai/integrations/claude-code/pubchem-compound-search)
- [Cline](https://spiral.ai/integrations/cline/pubchem-compound-search)
- [Codex](https://spiral.ai/integrations/codex/pubchem-compound-search)
- [Cursor](https://spiral.ai/integrations/cursor/pubchem-compound-search)
- [Devin](https://spiral.ai/integrations/devin/pubchem-compound-search)
- [dots](https://spiral.ai/integrations/dots/pubchem-compound-search)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/pubchem-compound-search)
- [Gemini](https://spiral.ai/integrations/gemini/pubchem-compound-search)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/pubchem-compound-search)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/pubchem-compound-search)
- [goose](https://spiral.ai/integrations/goose/pubchem-compound-search)
- [Grok](https://spiral.ai/integrations/grok/pubchem-compound-search)
- [Grok Build](https://spiral.ai/integrations/grok-build/pubchem-compound-search)
- [Hermes](https://spiral.ai/integrations/hermes/pubchem-compound-search)
- [Instinct](https://spiral.ai/integrations/instinct/pubchem-compound-search)
- [Manus](https://spiral.ai/integrations/manus/pubchem-compound-search)
- [Muse](https://spiral.ai/integrations/muse/pubchem-compound-search)
- [Muse Code](https://spiral.ai/integrations/muse-code/pubchem-compound-search)
- [n8n](https://spiral.ai/integrations/n8n/pubchem-compound-search)
- [Notion](https://spiral.ai/integrations/notion/pubchem-compound-search)
- [OpenClaw](https://spiral.ai/integrations/openclaw/pubchem-compound-search)
- [Perplexity](https://spiral.ai/integrations/perplexity/pubchem-compound-search)
- [Raycast](https://spiral.ai/integrations/raycast/pubchem-compound-search)
- [VS Code](https://spiral.ai/integrations/vscode/pubchem-compound-search)
- [Windsurf](https://spiral.ai/integrations/windsurf/pubchem-compound-search)
- [Zapier](https://spiral.ai/integrations/zapier/pubchem-compound-search)

## More opencode guides

- [PubChem compound patents](https://spiral.ai/integrations/opencode/pubchem-compound-patents)
- [PubChem compound targets](https://spiral.ai/integrations/opencode/pubchem-compound-targets)
- [PubChem compound details](https://spiral.ai/integrations/opencode/pubchem-compound-details)
- [PubChem similar compounds](https://spiral.ai/integrations/opencode/pubchem-similar-compounds)
- [PubChem compound bioassays](https://spiral.ai/integrations/opencode/pubchem-compound-bioassays)
- [PubMed and PMC article ID lookup](https://spiral.ai/integrations/opencode/pubmed-and-pmc-article-id-lookup)

## Questions about PubChem compound search in opencode

**Can opencode use PubChem compound search?**

Yes. Add Spiral to opencode as an MCP server, and opencode can find and run PubChem compound search like any built-in tool.

**How much does PubChem compound search cost in opencode?**

$0.00873 per call. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your opencode plan is separate.

**Do I need an Alexandria account to use PubChem compound search in opencode?**

No. Spiral runs PubChem compound search on its own Alexandria account. You sign in to Spiral once and never paste a key.

**How long does it take to set up PubChem compound search in opencode?**

About two minutes: add the server, then sign in, then check it.

**Does opencode wait while PubChem compound search runs?**

PubChem compound search runs in the background. opencode starts the run, checks on it and gives you the json when it's ready.

**Does PubChem cover only small molecules?**

Small molecules make up most of PubChem, but it also includes nucleotides, carbohydrates, lipids, peptides, and chemically modified macromolecules.

**Why can several submitted records lead to one CID?**

PubChem combines submitted Substance records that standardize to the same chemical structure into one Compound record. The CID identifies that structure, while the original submissions retain their Substance identifiers.

**Are PubChem CAS-number matches authoritative?**

PubChem does not verify or manually curate CAS numbers supplied by third parties. Its documentation explicitly warns that CAS-to-CID assignments can contain errors or inconsistencies.

**Does PubChem publish new data on a guaranteed daily schedule?**

PubChem says a daily processing cycle is not a publication guarantee. Submission size, processing, reviews, revision requests, and service workload affect when contributed data becomes public.

**Can a PubChem structure search miss matching compounds?**

Yes. A formula or structure search can stop at an operational time or result limit before examining every candidate, leaving a valid but incomplete result list whose count is a lower bound.

