Meeting minutes from a recording
Upload a meeting recording and get structured minutes (summary, topics, decisions, action items) as JSON and as a PDF, optionally with your company logo. Sequence:
GET /api/v1/meetings/pricing→POST /api/v1/meetings/jobs(multipart, holds Fara) → pollGET /api/v1/meetings/jobs/{id}→GET /api/v1/meetings/jobs/{id}/jsonandGET /api/v1/meetings/jobs/{id}/pdf.
At a glance#
- Base path:
/api/v1/meetings - Auth:
Authorization: Bearer fara_sk_...(Authentication) - Scope:
readfor GET,writefor everything else - Spends Fara: yes.
POST /api/v1/meetings/jobsholds Fara.POST /api/v1/meetings/jobs/{id}/retryon afailedjob holds Fara again. Pricing, branding, download and cancel calls are free. - Async: yes. Usually a few minutes; longer for long recordings.
- Terminal statuses:
completed,failed,cancelled(failedcan be retried with a new hold) - Review: the review endpoints exist, but new jobs do not stop for review today (see Review)
- Webhook events:
meeting.completed,meeting.failed,meeting.cancelled(meeting.awaiting_reviewexists but is not sent for new jobs) - Output: minutes JSON, PDF, Word file, one-page A4 summary, transcript (JSON, TXT, SRT, VTT), and a mind map when asked for
- Large files or unreliable connections: send the recording in chunks (up to 1 GB), then create the job with
{ "uploadId": "upl_..." }— see Upload large recordings in chunks - Upload by link: send
audioUrl(an https link) in a JSON body instead of a file. Any account. - Early access: timed minutes, chapters, speaker names,
externalId, a word list, meeting context, revising by instruction with undo, more documents, branding, categories, delete, and paid tools (highlights, ask, analytics, recap email, digest) — Meetings: early-access features
Before you start#
Price#
GET /api/v1/meetings/pricing HTTP/1.1
Authorization: Bearer fara_sk_...Response 200 OK:
{
"faraPerMin": 0.78,
"faraPerMinTranscript": 0.66,
"maxDurationSeconds": 14400,
"outputs": ["full", "summary", "key_points", "transcript"],
"outputLanguages": ["fa", "en"]
}curl -sS "https://faraatarjomeh.com/api/v1/meetings/pricing" -H "Authorization: Bearer $FARA_API_KEY"faraPerMin is a typical rate for minutes (output full, summary or key_points); faraPerMinTranscript for the transcript alone. Estimate: ceil(durationSeconds / 60) × faraPerMin. The exact hold is computed from the real length after upload and returned as cost.faraCharged in the create answer. If that is above the user's budget, cancel the job at once: the hold is released and nothing is charged.
Limits#
| Limit | Value |
|---|---|
| Upload field | multipart/form-data, file field audio (one file) |
| File types | The file part's Content-Type must be one of audio/mpeg, audio/mp4, audio/x-m4a, audio/wav, audio/x-wav, audio/webm, audio/ogg, audio/flac. The file content must also be MP3, WAV, M4A/MP4, OGG, FLAC or WebM. A part sent as application/octet-stream is dropped and you get 400. |
| File size | 200 MB (209,715,200 bytes) |
| Duration | maxDurationSeconds from pricing (today 14,400 s = 4 hours) |
| Billing unit | Whole minutes, rounded up, at least 1 |
| Rate limits | 120 requests per 60 s per API key; job creation 300 uploads per hour per account |
Steps#
1. Upload the recording#
Send an Idempotency-Key (a new UUID per upload). A success (and a 500/502/504) is stored for 24 hours: sending the same key again returns that first answer and never charges twice. A 4xx or 503 answer is not stored, so after you fix the request (or the user tops up) you can send it again with the same key. The key does not cover the file content, so never reuse a key for a different file.
POST /api/v1/meetings/jobs HTTP/1.1
Authorization: Bearer fara_sk_...
Idempotency-Key: 8c0f5e2a-1d7b-4b8e-9f3a-6e2d4c1b0a97
Content-Type: multipart/form-data; boundary=----fara
------fara
Content-Disposition: form-data; name="language"
en
------fara
Content-Disposition: form-data; name="outputLanguage"
fa
------fara
Content-Disposition: form-data; name="output"
summary
------fara
Content-Disposition: form-data; name="mindmap"
true
------fara
Content-Disposition: form-data; name="audio"; filename="weekly-sync.mp3"
Content-Type: audio/mpeg
<binary audio>
------fara--Response 201 Created:
{
"jobId": "66f5b7e1c3a2d4f6e8b01a2c",
"cost": { "faraCharged": 36, "minutesBilled": 46 },
"durationSeconds": 2712.4,
"outputOptions": { "outputLanguage": "fa", "output": "summary", "mindmap": true }
}curl -sS -X POST "https://faraatarjomeh.com/api/v1/meetings/jobs" \
-H "Authorization: Bearer $FARA_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "language=en" \
-F "outputLanguage=fa" \
-F "output=summary" \
-F "mindmap=true" \
-F "audio=@weekly-sync.mp3;type=audio/mpeg"Form fields#
| Field | Type | Required | Default | Allowed values | Notes |
|---|---|---|---|---|---|
audio |
file | yes | — | see Limits | One audio file. |
language |
string | no | auto |
auto, en, fa |
The spoken language (source), as a hint for speech recognition. Any other value is read as auto. |
outputLanguage |
string | no | the meeting's language | fa, en |
The minutes language (target): the minutes are written in it whatever language was spoken. Not used with output: transcript (the transcript stays in the spoken language). |
output |
string | no | full |
full, summary, key_points, transcript |
The document to make — see Documents. |
mindmap |
boolean | no | false |
true, false |
Also draw a mind map of the minutes. Free. Not with output: transcript (400). |
Documents#
output |
The PDF (GET /api/v1/meetings/jobs/{id}/pdf) |
Price |
|---|---|---|
full |
Complete minutes: summary, attendees, topics with discussion and key points, decisions, action items, open questions, next meeting. | faraPerMin |
summary |
One page to read: the summary, decisions as statements, the action items table, next meeting. | faraPerMin |
key_points |
Bullets only: each topic's key points, decisions, action items (task · owner · due), open questions. | faraPerMin |
transcript |
The timed transcript alone, one block per speaker turn with names and times. No minutes are written. | faraPerMinTranscript |
GET /api/v1/meetings/jobs/{id}/json returns the minutes for every document except transcript (there it holds only the title and language). The timed transcript of any meeting job downloads with GET /api/v1/meetings/jobs/{id}/transcript?format=json|txt|srt|vtt (free).
With mindmap: true: GET /api/v1/meetings/jobs/{id}/mindmap returns the tree ({ title, root: { id, label, summary, children } }: the title, one branch per topic with its key points, then decisions, action items and open questions), and GET /api/v1/meetings/jobs/{id}/mindmap/pdf a one-page PDF. Both free.
Two more files from a finished meeting, free for every account: GET /api/v1/meetings/jobs/{id}/docx (the minutes as a Word file) and GET /api/v1/meetings/jobs/{id}/one-page/pdf (the summary, decisions and action items on one A4 page; a long meeting shows fewer items and says how many more are in the full minutes). Both are made on the first request and answer 409 MEETING_NOT_FINISHED until the job is done. A meeting made with output: transcript has no one-page summary (409 MEETING_HAS_NO_MINUTES).
2. Wait for the job#
GET /api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c HTTP/1.1
Authorization: Bearer fara_sk_...Response 200 OK (trimmed; the job is wrapped in job):
{
"job": {
"_id": "66f5b7e1c3a2d4f6e8b01a2c",
"status": "completed",
"stage": "done",
"progress": 100,
"originalFilename": "weekly-sync.mp3",
"audioDurationSeconds": 2712.4,
"language": "en",
"reviewVersion": 0,
"transcript": {
"languageCode": "eng",
"fullText": "Okay, let's start. First item is the launch date...",
"speakers": [ { "id": "speaker_0", "turns": 41 }, { "id": "speaker_1", "turns": 37 } ],
"audioDurationSecs": 2712.4,
"wordCount": 6120
},
"minutes": { "language": "en", "direction": "ltr", "title": "Weekly product sync", "summary": "...", "...": "..." },
"warnings": [],
"readOnly": false,
"cost": { "faraCharged": 33, "minutesBilled": 46, "heldFara": 36, "refundedFara": 3 },
"customerErrorCode": null,
"createdAt": "2026-09-25T09:00:02.000Z",
"updatedAt": "2026-09-25T09:06:40.000Z",
"completedAt": "2026-09-25T09:06:40.000Z",
"failedAt": null
}
}curl -sS "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c" -H "Authorization: Bearer $FARA_API_KEY"Poll every 20 seconds, or use webhooks. Stop on completed, failed or cancelled.
Query ?full=1 returns the transcript's word-level timings in transcript.words instead of wordCount. It can be several MB; ask for it only when you need it.
Job fields you use#
| Field | Type | Notes |
|---|---|---|
_id |
string | Job id (24 hex characters). |
status |
string | See State machine. |
stage |
string | Progress label for display only: queued, uploading_audio, transcribing, summarizing, review, rendering_pdf, finalizing, done. More values can appear. |
progress |
number | 0–100. |
originalFilename, audioDurationSeconds, language |
From the upload. | |
transcript |
object or null | languageCode (detected, 3-letter code), fullText, speakers (id, turns), audioDurationSecs, wordCount. |
minutes |
object or null | The minutes. Same object as GET /api/v1/meetings/jobs/{id}/json. |
warnings |
array | Items { code, message, messageFa, generatedAt }. Today only MEETING_MINUTES_SCHEMA_REPAIRED: some minutes fields were missing and were filled in; ask the user to check them. |
reviewVersion |
integer | For If-Match on review calls. |
readOnly |
boolean | false for your own jobs. |
cost |
object | faraCharged is the hold while running, the real charge once completed (then also heldFara, refundedFara). |
customerErrorCode |
string or null | Why a failed job failed. |
3. Get the minutes#
JSON (available as soon as minutes is set):
GET /api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/json HTTP/1.1
Authorization: Bearer fara_sk_...Response 200 OK:
{
"minutes": {
"language": "en",
"direction": "ltr",
"title": "Weekly product sync",
"date": "2026-09-24",
"dateLabel": "Wednesday the 24th",
"attendees": [
{ "name": "Sara Ahmadi", "role": "Product lead" },
{ "name": "Speaker 2", "role": "" }
],
"absentees": [],
"summary": "The team moved the launch to October 6 and agreed on the pricing page copy.",
"topics": [
{ "title": "Launch date", "discussion": "QA needs one more week.", "keyPoints": ["Launch moves to Oct 6"] }
],
"decisions": [
{ "topic": "Launch date", "decision": "Launch on October 6.", "rationale": "QA needs one more week." }
],
"actionItems": [
{ "owner": "Sara Ahmadi", "task": "Tell the sales team the new date.", "dueDate": "2026-09-26", "dueLabel": "by Friday" }
],
"openQuestions": ["Do we need a new press release?"],
"nextMeeting": "Next Wednesday, same time"
}
}curl -sS "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/json" -H "Authorization: Bearer $FARA_API_KEY"| Minutes field | Type | Notes |
|---|---|---|
language |
string | en, fa, or another lowercase value for other languages. |
direction |
string | rtl or ltr. |
title, summary, nextMeeting |
string | In the meeting's language. Empty string when unknown. |
date |
string | ISO date (YYYY-MM-DD, Gregorian) or "". |
dateLabel |
string | The date as spoken, or "". |
attendees |
array | { name, role }. An unnamed speaker shows as a speaker id (speaker_0) or a label like Speaker 2. |
absentees, openQuestions |
string array | |
topics |
array | { title, discussion, keyPoints: string[] } |
decisions |
array | { topic, decision, rationale } |
actionItems |
array | { owner, task, dueDate, dueLabel }. dueDate is ISO or "". |
PDF (needs status: "completed", else 409):
GET /api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/pdf HTTP/1.1
Authorization: Bearer fara_sk_...Response 200 OK, Content-Type: application/pdf, Content-Disposition: attachment with the meeting title as file name. No Range support.
curl -sS -o minutes.pdf "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/pdf" -H "Authorization: Bearer $FARA_API_KEY"To list jobs: GET /api/v1/meetings/jobs?limit=20&offset=0 → { "jobs": [ ... ] } (newest first, limit at most 50, list items are short). Add q to search by name: the name you gave the job or its original file name, ignoring case, at most 100 characters.
Company logo on the PDF (optional)#
The logo is saved on the account and printed on every minutes PDF made after the upload. PDFs made before are not changed.
| Call | What it does |
|---|---|
GET /api/v1/meetings/branding |
{ "logo": { "mimeType", "byteSize", "updatedAt" } or null, "maxBytes": 2097152, "allowedTypes": ["image/png", "image/jpeg", "image/webp"] } |
POST /api/v1/meetings/branding/logo |
Multipart, file field logo. PNG, JPEG or WebP, at most 2 MB. Replaces any old logo. 201 → { "logo": { "mimeType": "image/png", "byteSize": 48213, "updatedAt": "..." } } |
GET /api/v1/meetings/branding/logo |
The image bytes. 404 if none. |
DELETE /api/v1/meetings/branding/logo |
Removes it. { "ok": true }, or 404 if none. |
POST /api/v1/meetings/branding/logo HTTP/1.1
Authorization: Bearer fara_sk_...
Content-Type: multipart/form-data; boundary=----fara
------fara
Content-Disposition: form-data; name="logo"; filename="logo.png"
Content-Type: image/png
<binary image>
------fara--Response 201 Created:
{ "logo": { "mimeType": "image/png", "byteSize": 48213, "updatedAt": "2026-09-25T08:55:00.000Z" } }curl -sS -X POST "https://faraatarjomeh.com/api/v1/meetings/branding/logo" \
-H "Authorization: Bearer $FARA_API_KEY" -F "logo=@logo.png;type=image/png"The part's Content-Type must be image/png, image/jpeg or image/webp, and the bytes must really be that type (SVG is refused).
Cancel#
POST /api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/cancel HTTP/1.1
Authorization: Bearer fara_sk_...Response 200 OK: { "ok": true }. The hold is released. Works from pending, active, awaiting_review and failed. 409 once completed or cancelled, or when the last step has started (stage is finalizing or done).
curl -sS -X POST "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/cancel" -H "Authorization: Bearer $FARA_API_KEY"Retry#
POST /api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/retry HTTP/1.1
Authorization: Bearer fara_sk_...
Idempotency-Key: 2a9e4b71-0c3d-4f5e-8a6b-7c8d9e0f1a2b| Job status | Response 200 OK |
Fara |
|---|---|---|
failed |
{ "ok": true } |
Holds cost.faraCharged again. Restarts from the start, or from the PDF step if the minutes were already done. |
pending_finalization |
{ "ok": true, "queued": true, "name": "resume" } |
Uses the existing hold. Finishes the charge and publishes. |
Other statuses → 409. If the uploaded audio is no longer stored → 409 SOURCE_AUDIO_NOT_FOUND; upload it again as a new job. If another retry changed the job at the same moment → 409 ("job retry state changed"); the hold this call took is released, so GET the job and decide again.
curl -sS -X POST "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c/retry" \
-H "Authorization: Bearer $FARA_API_KEY" -H "Idempotency-Key: $(uuidgen)"Review endpoints#
Meeting jobs go from summary straight to the PDF; they never stop at awaiting_review and no meeting.awaiting_review event is sent. PATCH …/minutes and POST …/approve below were removed for API keys on 2026-09-29 (they answer 410 GONE). To change finished minutes, use POST /api/v1/meetings/jobs/{id}/minutes/revise (early access). Renaming speakers works on finished meetings.
| Call | Body | Notes |
|---|---|---|
GET /api/v1/meetings/jobs/{id}/speakers |
— | Works in any status once the transcript exists (404 before). { "speakers": [ { "speakerId": "speaker_0", "id": "speaker_0", "name": "", "source": "diarizationOnly", "matchConfidence": 0, "talkSeconds": 1210, "turns": 41, "seconds": 1210, "samples": ["up to 3 of their longest turns"] } ], "language": "en" }. Sorted by speaking time. |
POST /api/v1/meetings/jobs/{id}/speakers |
{ "names": { "speaker_0": { "name": "Sara Ahmadi", "role": "Product lead" } } } |
Needs If-Match. Replaces the speaker id everywhere in the minutes. Keys must be speaker_<n> or unknown; others are ignored. A blank name leaves the id. Answer: { "ok": true, "minutes": { ... }, "reviewVersion": 1 }. |
PATCH /api/v1/meetings/jobs/{id}/minutes |
{ "minutes": { ...full minutes object... } } |
Needs If-Match. Replaces the whole minutes object. Answer: { "ok": true, "reviewVersion": 2 }. |
POST /api/v1/meetings/jobs/{id}/approve |
— | Needs If-Match. Makes the PDF from the current minutes. Uses the existing hold. Answer: { "ok": true, "status": "active", "reviewVersion": 2 }. |
If-Match is the job's reviewVersion, bare (If-Match: 1) or quoted (If-Match: "1"). Missing → 428 REVIEW_VERSION_REQUIRED. Old → 409 REVIEW_VERSION_CONFLICT with currentVersion. Each successful edit adds 1.
State machine#
status |
Terminal? | Meaning | Next action for the client |
|---|---|---|---|
pending |
no | Queued, transcribing or summarizing. | Poll. |
awaiting_review |
no | Waiting for review. Not used by new jobs today. A job left here for 3 days is cancelled and refunded. | Edit, then approve; or cancel. |
active |
no | Making the PDF. | Poll. |
retrying |
no | A retry call is being set up. Lasts seconds. |
Poll. |
finalizing |
no | Charging and publishing. Cannot be cancelled. | Poll. |
pending_finalization |
no | The PDF is made but the charge did not go through. The result is held back. | Call retry (no new hold), or wait. |
completed |
yes | Done and charged. | Download JSON and PDF. |
failed |
yes (retryable) | Stopped. Hold released. customerErrorCode says why. |
Retry once for SERVICE_BUSY, TOOK_TOO_LONG or GENERIC. Do not retry NO_SPEECH_FOUND or MEDIA_TOO_LONG. |
cancelled |
yes | Cancelled. Hold released. | Nothing. |
Transitions: create → pending → active → finalizing → completed. Any error → failed. cancel → cancelled. retry on failed → retrying → pending or active. A failed charge → pending_finalization → (retry) → finalizing. Treat any other status as still running.
Billing#
POST /api/v1/meetings/jobsmeasures the recording and holds the price for its length (cost.faraCharged).402if the balance is too low; nothing is held on any4xx.- When the PDF is made, the real cost is charged. If it is above the hold, the difference is charged as an extra ledger row when your balance covers it; if it does not, only the hold is charged. Anything held and not used is released (
cost.heldFara,cost.refundedFara). - On
failedorcancelledthe whole hold is released. retryon afailedjob holds the same amount again and follows steps 2–3.
The same recording (the same file, byte for byte) sent again by the same account within 7 days, as a meeting job or an audio-to-text job, is transcribed once: later jobs reuse that text, so the words, timings and speakers are the same. Each job is still charged as above. The stored text is deleted after 7 days, or earlier when the job it came from is deleted. It is never used for another account.
For minutes and a transcript of one recording, create only the meeting job: its transcript downloads as JSON, TXT, SRT or VTT with GET /api/v1/meetings/jobs/{id}/transcript (early access). A second audio-to-text job for the same file is a second charge.
See Billing.
Webhook events#
| Event | When |
|---|---|
meeting.completed |
Minutes and PDF are ready. |
meeting.failed |
The job failed. data.customerErrorCode says why. |
meeting.cancelled |
The job was cancelled. |
meeting.awaiting_review |
A job stopped for review. Not sent for new jobs today. |
Payload: { "type": "meeting.completed", "timestamp": "...", "id": "evt_...", "data": { "object": "meeting", "id": "66f5b7e1c3a2d4f6e8b01a2c", "status": "completed", "createdAt": "...", "updatedAt": "...", "links": { "self": "https://faraatarjomeh.com/api/v1/meetings/jobs/66f5b7e1c3a2d4f6e8b01a2c" } } }. GET links.self for the current state. See Webhooks.
Errors and recovery#
All errors are application/problem+json. Branch on code. See Errors.
| HTTP | code |
When | Retry? | What the client should do |
|---|---|---|---|---|
| 400 | BAD_REQUEST |
No audio part, part type not allowed, content is not audio, duration unreadable, longer than maxDurationSeconds, or file over 200 MB. |
no | Fix the file: check the part's Content-Type, the format, the length and the size. |
| 402 | INSUFFICIENT_CREDITS |
Balance below the hold. Body has cost ({ faraCharged, minutesBilled }, the hold) and balance. |
no | Tell the user the price and balance; they top up at https://faraatarjomeh.com. After the top-up, send the same request again; the same Idempotency-Key is fine (4xx answers are not stored). |
| 402 | CHARGEBACK_LIABILITY_OUTSTANDING |
A payment was reversed. | no | Tell the user to settle it on the website. |
| 404 | NOT_FOUND |
No such job; transcript, minutes or PDF not ready; no logo. | no | Check the id or wait for the job. |
| 404 | FEATURE_DISABLED |
Meeting minutes are off on this server. | later | Try again much later. |
| 409 | CONFLICT |
Wrong status for the call (review call outside review, PDF before completed, cancel after finalizing, retry of a job that is not failed/pending_finalization). |
refresh | GET the job and decide from status. |
| 409 | SOURCE_AUDIO_NOT_FOUND |
Retry needs the audio, which is gone. | no | Upload again as a new job. |
| 409 | HOLD_NOT_FOUND |
The job's hold is gone. | no | Create a new job. |
| 409 | REVIEW_VERSION_CONFLICT |
Old If-Match. |
refresh | GET the job, rebuild the edit, send the new version. |
| 428 | REVIEW_VERSION_REQUIRED |
If-Match missing on a review call. |
yes | Add If-Match: <reviewVersion>. |
| 409 | IDEMPOTENCY_KEY_IN_USE |
First request with this key still running. | yes | Wait Retry-After, resend the same request with the same key. |
| 429 | RATE_LIMITED |
Too many requests. | yes | Wait Retry-After seconds. |
| 500, 502, 504 | INTERNAL_ERROR, UPSTREAM_ERROR, UPSTREAM_TIMEOUT |
Unknown outcome: the job may or may not exist. This answer is stored, so the same Idempotency-Key only replays it. |
check first | List jobs with GET /api/v1/meetings/jobs and look for one with the same originalFilename created in the last minutes. Only if there is none, send the request again with a NEW Idempotency-Key. |
| 503 | CREDIT_RESERVATION_UNAVAILABLE |
Could not hold Fara right now. | yes | Wait Retry-After, upload again with the same Idempotency-Key. |
| 503 | SERVICE_UNAVAILABLE |
Could not queue the job; hold released. | yes | Back off, upload again with the same Idempotency-Key. |
A file over 200 MB answers 400 with code FILE_TOO_LARGE. Send larger files as a chunked upload.
Rules for agents#
- Get the rate first. After upload, compare
cost.faraChargedwith the user's budget; if it is higher, cancel at once. - Set the file part's
Content-Typeto the real audio type. Without it the upload is refused. - Use a new
Idempotency-Keyfor every file. Reuse it only to retry the same upload. - Poll no faster than every 20 seconds. Prefer webhooks.
- Branch on
codeandcustomerErrorCode, never ondetail. - Treat unknown
statusvalues as still running. - The minutes can contain personal data from the meeting. Only share them where the user said.
Complete script#
Both scripts: upload → poll → save the minutes JSON and the PDF. Set FARA_API_KEY, FARA_BASE_URL and MAX_FARA.
# Python 3.9+, pip install requests
import os, sys, time, uuid, json
import requests
BASE = os.environ.get("FARA_BASE_URL", "https://faraatarjomeh.com").rstrip("/")
H = {"Authorization": f"Bearer {os.environ['FARA_API_KEY']}"}
FILE = "weekly-sync.mp3"
MAX_FARA = 100
TYPES = {".mp3": "audio/mpeg", ".m4a": "audio/mp4", ".mp4": "audio/mp4", ".wav": "audio/wav",
".webm": "audio/webm", ".ogg": "audio/ogg", ".flac": "audio/flac"}
def check(r):
if r.status_code >= 400:
p = r.json() if "json" in r.headers.get("Content-Type", "") else {}
raise SystemExit(f"{r.status_code} {p.get('code')}: {p.get('detail')}")
return r
price = check(requests.get(f"{BASE}/api/v1/meetings/pricing", headers=H, timeout=30)).json()
print("about", price["faraPerMin"], "Fara per minute, max", price["maxDurationSeconds"], "s")
mime = TYPES[os.path.splitext(FILE)[1].lower()]
idem = str(uuid.uuid4()) # one key per file; reuse only to retry this upload (on 500/502/504 check the job list first)
for attempt in range(5):
with open(FILE, "rb") as f:
r = requests.post(f"{BASE}/api/v1/meetings/jobs", headers={**H, "Idempotency-Key": idem},
data={"language": "auto"}, files={"audio": (os.path.basename(FILE), f, mime)}, timeout=600)
if r.status_code in (409, 429, 503) and r.json().get("code") in ("IDEMPOTENCY_KEY_IN_USE", "RATE_LIMITED", "CREDIT_RESERVATION_UNAVAILABLE", "SERVICE_UNAVAILABLE"):
time.sleep(int(r.headers.get("Retry-After", 2 ** attempt)))
continue
break
created = check(r).json()
job_id = created["jobId"]
print("job:", job_id, "held:", created["cost"]["faraCharged"], "Fara")
if created["cost"]["faraCharged"] > MAX_FARA:
check(requests.post(f"{BASE}/api/v1/meetings/jobs/{job_id}/cancel", headers=H, timeout=30))
sys.exit("over budget; cancelled, hold released")
while True:
job = check(requests.get(f"{BASE}/api/v1/meetings/jobs/{job_id}", headers=H, timeout=60)).json()["job"]
print(job["status"], job.get("stage"), job.get("progress"))
if job["status"] in ("completed", "failed", "cancelled"):
break
time.sleep(20)
if job["status"] != "completed":
sys.exit(f"job ended as {job['status']} ({job.get('customerErrorCode')})")
minutes = check(requests.get(f"{BASE}/api/v1/meetings/jobs/{job_id}/json", headers=H, timeout=60)).json()["minutes"]
with open("minutes.json", "w", encoding="utf-8") as f:
json.dump(minutes, f, ensure_ascii=False, indent=2)
pdf = check(requests.get(f"{BASE}/api/v1/meetings/jobs/{job_id}/pdf", headers=H, timeout=300))
with open("minutes.pdf", "wb") as f:
f.write(pdf.content)
print("title:", minutes["title"], "charged:", job["cost"]["faraCharged"], "Fara")// Node.js 20+ (ESM: save as meeting.mjs)
import { openAsBlob } from "node:fs";
import { writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { basename, extname } from "node:path";
const BASE = (process.env.FARA_BASE_URL ?? "https://faraatarjomeh.com").replace(/\/+$/, "");
const H = { Authorization: `Bearer ${process.env.FARA_API_KEY}` };
const FILE = "weekly-sync.mp3";
const MAX_FARA = 100;
const TYPES = { ".mp3": "audio/mpeg", ".m4a": "audio/mp4", ".mp4": "audio/mp4", ".wav": "audio/wav", ".webm": "audio/webm", ".ogg": "audio/ogg", ".flac": "audio/flac" };
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function call(path, init = {}) {
const res = await fetch(`${BASE}${path}`, { ...init, headers: { ...H, ...init.headers } });
if (!res.ok) {
const p = await res.json().catch(() => ({}));
const err = new Error(`${res.status} ${p.code}: ${p.detail}`);
err.code = p.code;
err.retryAfter = Number(res.headers.get("retry-after")) || 0;
throw err;
}
return res;
}
const price = await (await call("/api/v1/meetings/pricing")).json();
console.log("about", price.faraPerMin, "Fara per minute, max", price.maxDurationSeconds, "s");
const idem = randomUUID(); // one key per file; reuse only to retry this upload (on 500/502/504 check the job list first)
const RETRY = new Set(["IDEMPOTENCY_KEY_IN_USE", "RATE_LIMITED", "CREDIT_RESERVATION_UNAVAILABLE", "SERVICE_UNAVAILABLE"]);
let created;
for (let attempt = 0; ; attempt++) {
const form = new FormData();
form.append("language", "auto");
form.append("audio", await openAsBlob(FILE, { type: TYPES[extname(FILE).toLowerCase()] }), basename(FILE));
try {
created = await (await call("/api/v1/meetings/jobs", { method: "POST", headers: { "Idempotency-Key": idem }, body: form })).json();
break;
} catch (e) {
if (!RETRY.has(e.code) || attempt >= 4) throw e;
await sleep((e.retryAfter || 2 ** attempt) * 1000);
}
}
const jobId = created.jobId;
console.log("job:", jobId, "held:", created.cost.faraCharged, "Fara");
if (created.cost.faraCharged > MAX_FARA) {
await call(`/api/v1/meetings/jobs/${jobId}/cancel`, { method: "POST" });
throw new Error("over budget; cancelled, hold released");
}
let job;
for (;;) {
({ job } = await (await call(`/api/v1/meetings/jobs/${jobId}`)).json());
console.log(job.status, job.stage, job.progress);
if (["completed", "failed", "cancelled"].includes(job.status)) break;
await sleep(20_000);
}
if (job.status !== "completed") throw new Error(`job ended as ${job.status} (${job.customerErrorCode})`);
const { minutes } = await (await call(`/api/v1/meetings/jobs/${jobId}/json`)).json();
await writeFile("minutes.json", JSON.stringify(minutes, null, 2));
const pdf = await call(`/api/v1/meetings/jobs/${jobId}/pdf`);
await writeFile("minutes.pdf", Buffer.from(await pdf.arrayBuffer()));
console.log("title:", minutes.title, "charged:", job.cost.faraCharged, "Fara");