> ## Documentation Index
> Fetch the complete documentation index at: https://docs.medera.info/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart — Real-time Ambient Scribe

> Build a real-time SOAP scribe in under 20 minutes.

Spin up a real-time ambient scribe with the AI Services clinical endpoints — diarized capture, in-encounter SOAP drafting, ICD-10 / CPT code suggestions, and EHR sync.

## Architecture

<Frame>
  <svg viewBox="0 0 720 380" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="medera/ambient-rt.svg" style={{ width: '100%', height: 'auto', display: 'block', maxWidth: '780px', margin: '24px auto' }}><defs><pattern id="mdr-dots" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse"><circle cx="1" cy="1" r="1" fill="rgba(0,0,0,0.08)" /></pattern></defs><rect x="0" y="0" width="720" height="380" fill="#ffffff" /><rect x="0" y="0" width="720" height="32" fill="#141413" /><circle cx="14" cy="16" r="3" fill="#ff5f57" /><circle cx="26" cy="16" r="3" fill="#febc2e" /><circle cx="38" cy="16" r="3" fill="#28c840" /><text x="54" y="20" fill="#9a9893" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="11" fontWeight="500">medera/ambient-rt.svg</text><text x="706" y="20" textAnchor="end" fill="#9a9893" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10">ambient scribe quickstart</text><rect x="0" y="32" width="720" height="348" fill="#fafaf6" /><rect x="0" y="32" width="720" height="348" fill="url(#mdr-dots)" /><rect x="0.5" y="0.5" width="719" height="379" fill="none" stroke="#141413" strokeOpacity="0.18" /><text x="360.0" y="56" textAnchor="middle" fill="#141413" fontFamily="Inter, sans-serif" fontSize="15" fontWeight="600">Ambient scribe — real time</text><rect x="199.0" y="108.0" width="136" height="44" fill="#76a1fc" stroke="#4f7be0" strokeWidth="1" /><text x="267.0" y="134" textAnchor="middle" fill="#ffffff" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10" fontWeight="700">Open WSS /sessions</text><line x1="330.0" y1="130" x2="342.0" y2="130" stroke="rgba(20,20,19,0.40)" strokeWidth="1.5" /><polygon points="342.0,126 342.0,134 348.0,130" fill="rgba(20,20,19,0.25)" /><rect x="361.0" y="108.0" width="160" height="44" fill="#ffffff" stroke="rgba(0,0,0,0.08)" strokeWidth="1" /><text x="441.0" y="134" textAnchor="middle" fill="#141413" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10" fontWeight="600">Stream encounter audio</text><path d="M 660 152.0 Q 672 167.0 660 182.0 L 60 182.0 Q 48 197.0 60 212.0" stroke="rgba(20,20,19,0.40)" strokeWidth="1.5" fill="none" /><rect x="157.0" y="212.0" width="190" height="44" fill="#ffffff" stroke="rgba(0,0,0,0.08)" strokeWidth="1" /><text x="252.0" y="238" textAnchor="middle" fill="#141413" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10" fontWeight="600">Receive diarized transcript</text><line x1="342.0" y1="234" x2="354.0" y2="234" stroke="rgba(20,20,19,0.40)" strokeWidth="1.5" /><polygon points="354.0,230 354.0,238 360.0,234" fill="rgba(20,20,19,0.25)" /><rect x="373.0" y="212.0" width="190" height="44" fill="#ffffff" stroke="rgba(0,0,0,0.08)" strokeWidth="1" /><text x="468.0" y="238" textAnchor="middle" fill="#141413" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10" fontWeight="600">Receive SOAP + ICD-10 + CPT</text><rect x="60" y="220" width="600" height="48" fill="#141413" stroke="none" strokeWidth="1" /><text x="360.0" y="240" textAnchor="middle" fill="#ffffff" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="12" fontWeight="600">wss\://api.medera.info/sessions</text><text x="360.0" y="258" textAnchor="middle" fill="#dbe5ff" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10">WSS · real-time stateful transcription</text><text x="360.0" y="300" textAnchor="middle" fill="#5c5c5a" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10">2-speaker diarization · DSM-5-TR vocab bias · instrument-score extraction</text><text x="360.0" y="320" textAnchor="middle" fill="#5c5c5a" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontSize="10">C-SSRS in-line crisis marker · structured SOAP draft</text></svg>
</Frame>

## Prerequisites

* A

Medera Console account and a Developer API Key with `write:phi` and `execute:agents` scopes.

* A microphone — see [Microphone Devices](/multimodal/stt/microphones).

* An EHR target configured under **Console → Integrations**.

<Steps>
  <Step title="Authenticate">
    Set your API key as an env variable.

    ```bash theme={"system"}
    export MEDERA_API_KEY="<your-key>" 
    ```
  </Step>

  <Step title="Start the clinical session">
    Open a clinical session — this anchors the transcript, note, and code suggestions.

    <CodeGroup>
      ```typescript JavaScript theme={"system"}
      import { MederaClient } from '@medera/sdk'; const client = new MederaClient({ apiKey: process.env.MEDERA_API_KEY! }); const { session_id } = await client.clinical.start({ session_type: 'clinical_visit', patient_id: 'pat_abc', }); 
      ```

      ```python Python theme={"system"}
      from medera import MederaClient client = MederaClient(api_key=os.environ["MEDERA_API_KEY"]) session = client.clinical.start(session_type="clinical_visit", patient_id="pat_abc",) 
      ```

      ```bash theme={"system"}
      cURL curl -X POST https://api.medera.info/api/clinical/start \ -H "X-API-Key: $MEDERA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "session_type": "clinical_visit", "patient_id": "pat_abc" }' 
      ```
    </CodeGroup>
  </Step>

  <Step title="Stream chunks">
    Send PCM audio chunks (16 kHz 16-bit mono recommended) as the clinician speaks.

    <CodeGroup>
      ```typescript JavaScript theme={"system"}
      // Encode PCM as base64 const audio_data = btoa(String.fromCharCode(...pcmBuffer)); const { transcript } = await client.clinical.chunk({ session_id, audio_data, }); 
      ```

      ```python Python theme={"system"}
      import base64 audio_b64 = base64.b64encode(pcm_buffer).decode res = client.clinical.chunk(session_id=session.id, audio_data=audio_b64,) 
      ```

      ```bash theme={"system"}
      cURL curl -X POST https://api.medera.info/api/clinical/chunk \ -H "X-API-Key: $MEDERA_API_KEY" \ -d '{ "session_id": "ses_abc", "audio_data": "<base64 PCM>" }' 
      ```
    </CodeGroup>

    Local Medera STT is the default with Medera STT as fallback. The response returns the accumulated transcript so far.
  </Step>

  <Step title="Stop the session">
    Finalize the transcript and trigger the initial clinical analysis.

    <CodeGroup>
      ```typescript JavaScript theme={"system"}
      const result = await client.clinical.stop({ session_id }); // result.transcription, result.clinical_data 
      ```

      ```python Python theme={"system"}
      result = client.clinical.stop(session_id=session.id) 
      ```

      ```bash theme={"system"}
      cURL curl -X POST https://api.medera.info/api/clinical/stop \ -H "X-API-Key: $MEDERA_API_KEY" \ -d '{ "session_id": "ses_abc" }' 
      ```
    </CodeGroup>
  </Step>

  <Step title="Generate the SOAP note">
    Use the enhanced generator for specialty templates and inline code suggestions.

    <CodeGroup>
      ```typescript JavaScript theme={"system"}
      const note = await client.therapy.generateSoapNoteEnhanced({ session_data: { session_id }, specialty: 'psychiatry', template_config: { format_version: 'v3', include_assessments: true, include_billing_codes: true, }, }); 
      ```

      ```python Python theme={"system"}
      note = client.therapy.generate_soap_note_enhanced(session_data={"session_id": session.id}, specialty="psychiatry", template_config={ "format_version": "v3", "include_assessments": True, "include_billing_codes": True, },) 
      ```

      ```bash theme={"system"}
      cURL curl -X POST https://api.medera.info/api/therapy/generate-soap-note-enhanced \ -H "X-API-Key: $MEDERA_API_KEY" \ -d '{ "session_data": { "session_id": "ses_abc" }, "specialty": "psychiatry", "template_config": { "include_billing_codes": true } }' 
      ```
    </CodeGroup>

    The response includes the structured SOAP plus a list of suggested ICD-10 / CPT codes anchored to transcript spans.
  </Step>

  <Step title="Sign and post to the EHR">
    After clinician sign-off, finalize the note. Medera posts the signed note and code set to the configured EHR target via the integration adapter.

    ```bash theme={"system"}
    curl -X POST https://api.medera.info/api/therapy/notes/{note_id}/finalize \ -H "X-API-Key: $MEDERA_API_KEY" 
    ```
  </Step>
</Steps>

## Best practices -

Capture audio at **16 kHz 16-bit PCM mono**.

Higher rates work but waste bandwidth.

* Use a dedicated lavalier or beamforming mic. See [Microphone Devices](/multimodal/stt/microphones).

* Always require clinician sign-off before posting. Never auto-post to the EHR.

* Use the transcript span IDs to render the documentation anchor next to every code suggestion.

***

## What's next

<CardGroup cols={2}>
  <Card title="Visit Scribe Agent" icon="https://mintcdn.com/medera-357fd587/n1mgcc3nR2sq_PoL/icons/ui/stethoscope.svg?fit=max&auto=format&n=n1mgcc3nR2sq_PoL&q=85&s=c8a7441d30a2ae7471a136c60f734adc" href="/agentic/agents/visit-scribe" width="40" height="40" data-path="icons/ui/stethoscope.svg">
    Agent-level documentation.
  </Card>

  <Card title="Encounter Coding" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/code.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=55229463dbd5bbb579cce6192dbc5ffc" href="/coding/encounter-coding" width="40" height="40" data-path="icons/ui/code.svg">
    How code suggestions work.
  </Card>

  <Card title="EHR Integrations" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/link.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=44f5f1ae1b0122daa0138e9f47b49449" href="/api-reference/integrations/overview" width="40" height="40" data-path="icons/ui/link.svg">
    Connect Epic, Cerner, athenahealth.
  </Card>

  <Card title="STT — best practices" icon="https://mintcdn.com/medera-357fd587/iC-6rAuwl-0aQSw_/icons/ui/mic.svg?fit=max&auto=format&n=iC-6rAuwl-0aQSw_&q=85&s=2fa5bf2e6c0f7c96c6db63c83d109eb1" href="/multimodal/stt/best-practices-recording" width="40" height="40" data-path="icons/ui/mic.svg">
    Audio quality recommendations.
  </Card>
</CardGroup>
