AI agents and LLMs
Give AI assistants a tool that searches official medicine records instead of guessing from training data.
Define a search tool
Describe the search endpoint as a tool. Most model APIs accept a JSON Schema like this one:
{
"name": "search_medicines",
"description": "Search official medicine records of one country by brand name, active ingredient or national code. Returns records with their source, licence and limitations.",
"input_schema": {
"type": "object",
"properties": {
"country": {
"type": "string",
"description": "Two-letter lowercase country code, e.g. it, es, us."
},
"q": {
"type": "string",
"description": "Name, active ingredient or identifier, 3–120 characters."
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 50
}
},
"required": [
"country",
"q"
]
}
}
Run the tool
export async function searchMedicines({ country, q, limit = 10 }) {
const params = new URLSearchParams({ country, q, limit: String(limit) })
const response = await fetch(`https://api.medifontis.com/v1/drugs?${params}`, {
headers: { Authorization: `Bearer ${process.env.MEDIFONTIS_API_KEY}` },
})
if (!response.ok) return { error: (await response.json()).error }
const { results } = await response.json()
// Keep the fields a model needs, including where each record comes from.
return results.map(({ name, identifiers, sourceId, sourceUrl, licence, limitations }) => ({
name, identifiers, sourceId, sourceUrl, attribution: licence?.attribution, limitations,
}))
}
Grounding guidelines
- Cite the source and its attribution with every answer that uses a record.
- Never present a record as prescribing advice or proof of availability.
- Use identifiers, not names, for follow-up lookups.
Machine-readable documentation
The full contract is available as OpenAPI 3.1, and a summary for language models at /llms.txt.