Before you begin, install an SDK and set your API key. Each example below assumes
MEIBEL_API_KEY is set in your environment.1. Parse a document
Start by parsing a single document. It is the fastest way to see the platform do real work, and it confirms your SDK and API key are set up correctly before you build anything larger. Parsing turns a PDF, including scanned or image-based pages, into clean structured content you can read or hand to another step. The call runs synchronously, so the result comes straight back.result. Running it synchronously like this suits smaller files or testing a lighter workflow. For larger documents or higher volumes, submit the job asynchronously and poll for the result instead. See the document processing guide for that workflow.
2. Create a datasource and upload content
Parsing one document is useful on its own, but most work spans many documents that you want to search across and keep up to date. A datasource is a managed knowledge base for exactly that: you add files to it, and the platform parses, analyzes, indexes, and keeps them searchable. The agent you build in the next step will draw on this datasource to ground its answers. In this step you create a datasource, upload a few MSDS PDFs, and trigger ingestion. Download the sample sheets first, then upload them from your working directory:- Acetone safety data sheet (Avantor)
- Ethanol safety data sheet (Decon Laboratories)
- Acetic acid safety data sheet (SeaStar Chemicals)
- Citric acid safety data sheet (Chemfax)
- Potassium chlorate safety data sheet (Fisher Scientific)
3. Create an agent and chat with it
An agent is where your context turns into something you can use. It brings together what it knows, how it reasons, and what it produces: the datasources it can draw on, a system prompt that shapes its responses, and an optional schema for structured output. It can also call tools to improve an answer or take action, such as running a targeted search or querying a database. A sensitive tool can require human approval before it runs. Bound to your MSDS datasource, an agent retrieves the relevant content on its own to ground each answer, point to the source it drew from, and decline to guess when the answer is not there. Create an agent over the datasource from the previous step, then publish it. Publishing freezes the configuration as a versioned, reproducible release that can hold chat sessions.Stream a response
Streaming sends the response back in pieces as it is generated, instead of making you wait for the whole thing. It helps anywhere a wait would otherwise feel slow: a chat interface that shows the answer as it forms, a long-running task you want to report progress on, or a downstream process that can start on early output before the rest arrives. Send the message to the streaming endpoint and read events as they come in.connected, status, tool_call / tool_result (emitted when the agent retrieves from a datasource), partial_response (empty while a tool runs), and completion. The complete answer is always in the completion event’s data.message. Read that for the final text. Each partial_response carries the full text generated up to that point, so print the newly-added suffix for a live typing effect. See the streaming guide for the full event reference and semantics. To attach a file to a streaming turn, pass a file and file name as the second and third arguments (both optional).
4. Extract structured data from a document
Chat gives you answers in prose. Often you want structured data instead: the same fields, in the same shape, ready to store or compare. For that you define an artifact schema, a JSON Schema that names the fields you want, and have the platform extract a document into that shape. Start with the schema. It lists the chemical-property and safety fields to pull from each sheet. Every field is optional, so the platform returnsnull for anything a given sheet does not contain.
5. Run extraction across a datasource in batch
Extracting a document at a time works well for interactive, on-demand extraction, and for checking that your schema behaves. When you need the same structured extraction from every document in a datasource, run it as a batch: point an agent at the datasource, and it processes each file and returns one structured result per input document. The agent’s instructions are what drive the extraction, so give it a focused extraction prompt. This one works well for safety data sheets:- A clear role and task. “You are an MSDS data extractor” and “extract the following … from the attached document” keep the agent focused on extraction rather than conversation.
- An explicit output contract. It asks for a structured JSON artifact by name, matching the schema you registered.
- Every field named and described. A short description per field tells the agent exactly what to pull and resolves ambiguity between similar fields.
- A rule for missing data. “Use null for any field not found” keeps the agent faithful to the document instead of guessing.
- Grounded to the source. “From the attached document” anchors the extraction to the file rather than the model’s prior knowledge.
What’s next
You now have a complete Meibel pipeline: documents parsed, a searchable knowledge base, an agent you can chat with, and structured data pulled from a single document and from a whole datasource at once. Each step here is the simplest version of something you can take much further. Explore the ideas behind them next:Agents
Agent definitions, tools, publishing, and versioning
Confidence Scoring
How Meibel evaluates the quality of an agent’s work
Streaming
Streaming patterns for chat and processing