palmyra-med model. After completing these steps, you can analyze medical text using the palmyra-med model, which provides medical analysis capabilities within a chat completion workflow.
Compare the APIs
The medical comprehend API and the LLM tool with thepalmyra-med model both provide medical text analysis capabilities, but the LLM tool integrates medical analysis into conversational workflows and supports more flexible configuration and output options. The table below compares the two approaches.
| Aspect | Medical comprehend API | LLM tool with palmyra-med model |
|---|---|---|
| Endpoint | /v1/tools/comprehend/medical | /v1/chat with LLM tool specification in the tools array |
| Request structure | Pass text and analysis parameters such as content and response_type directly in the request body | Provide the medical text as part of the conversation messages and specify the analysis tool and model in the tools array. Additional parameters (such as custom instructions or output schema) are included in the tool configuration, not as direct request fields. |
| Response format | Structured JSON with a fixed schema (predefined medical entities and types) | Answer in choices[0].message.content as either natural language or structured JSON (including custom schemas or user-defined formats) |
| Parameter control | Explicit API parameters for each entity and type supported by the API | Most analysis details are defined by the message prompt and tool configuration; you can specify formats, schema, or request conversational output as needed |
Choose your migration approach
Choose your migration approach based on the type of output you need:-
Select the LLM tool with structured output if you require clearly defined, machine-readable results (for example, extracting predefined medical entities like
RxNorm,ICD-10-CM, orSNOMED CT). This option closely matches the original medical comprehend API response format and is best for downstream systems that depend on standardized data. - Choose conversational analysis with natural language responses if your use case benefits from more flexible or descriptive outputs, or if you want to define your own entity or analysis formats that are not supported by the original API. This approach is ideal for interactive workflows or when you want the model to summarize, explain, or provide guidance in plain language.
Extract entities and generate structured output
If you need structured entity extraction similar to the medical comprehend API, use the structured output feature with the LLM tool to get JSON responses:Analyze medical text with natural language responses
If you need conversational medical analysis and interpretation, use the LLM tool without structured output:Migrate your code
The tabs below show a request using the medical comprehend API and the same request using the LLM tool with thepalmyra-med model.
- Before: Medical comprehend API
- After: LLM tool with structured output
The medical comprehend API accepts medical text and a response type:Response:
Access LLM metadata
The LLM tool response includes metadata in thellm_data field: