/accountBalance, legal_version, scopes and current limits.
MCP: get_account
Developer guide
A compatible, authorized x402 client can fund a private session and receive its API key automatically. Existing account keys remain supported. Quote the work, approve the cost, and keep control of the result.
Start a signup-free session over REST, then use its funded API key with REST or remote MCP. If you already have a LyricPatch account key, skip bootstrap and connect directly.
Public OpenAPI schemaPython connector & examplesPublished MCP Registry recordMachine-readable guide
The public POST /v1/agent/sessions endpoint offers a private session with 40 non-expiring credits for $1.99, paid through x402 with USDC on Base. It does not need an existing LyricPatch login or agent key. The server creates a separate owner identity and issues an API key only after funding is confirmed.
lp_session_ followed by 64 cryptographically random hex characters. Save that secret securely before the first request; send it in X-LyricPatch-Session on every bootstrap and recovery request.GET /v1/agent/sessions/offer for public service information, or discover get_service_info through anonymous MCP initialization and tool listing. Then POST the session request: HTTP 402 returns the payment requirements and legal version. If you omit the session header, the server provides a session secret; a lost initial response is why generating your own first is recommended.PAYMENT-SIGNATURE and the confirmed attestations. An ordinary HTTP client cannot sign for your wallet.api_key privately. If payment is pending, recover the existing session and resume the same purchase when needed. Never create a new session as a payment retry.# HTTP protocol sketch — wallet signing is handled by your x402 client.
# FIRST generate "lp_session_" + secrets.token_hex(32) in your client.
# Persist it in a secret manager BEFORE making any network request.
# Use the SAME X-LyricPatch-Session value for this session on every retry.
POST /v1/agent/sessions
X-LyricPatch-Session: <your saved session secret>
Content-Type: application/json
{}
# 402: read PAYMENT-REQUIRED, the offer and current legal_version.
# Get actual permission for each attestation and the displayed purchase.
# Your wallet client signs this exact offer. Retry the SAME URL and secret:
POST /v1/agent/sessions
X-LyricPatch-Session: <the same saved session secret>
PAYMENT-SIGNATURE: <signature from your authorized x402 wallet>
Content-Type: application/json
{
"legal_version": "<current version from the offer>",
"adult_attested": true,
"terms_accepted": true,
"rights_attested": true,
"spending_authorized": true,
"media_processing_authorized": true
}
# The true values above are valid ONLY after actual delegated permission.
# 200 = confirmed funded session; store api_key privately.
# 202 = payment pending; do not start a new purchase/session.
# Recover using the SAME private session secret:
GET /v1/agent/sessions/current
X-LyricPatch-Session: <the same saved session secret>
# If payment needs resuming after its proof was recorded, POST the SAME
# session again without a new PAYMENT-SIGNATURE. Never buy a second session.
# Do not log session responses, session secrets, api_key or signed proofs.Keep the session secret to resume its paid balance and recover its credential. There is no email recovery for a lost signup-free session secret. It is not a public transaction receipt or an identifier to share with support. Funding does not itself authorize generation, alternate versions, exports or publication.
A client must support the REST bootstrap, file transfer and x402 wallet authorization. MCP also requires Streamable HTTP and custom bearer headers. A capable host can obtain the funded key and connect it programmatically; the person does not need to create a key or configure a website account manually. A prompt alone does not give every chat assistant these capabilities.
If you funded a signup-free session, use its returned API key and skip the account steps below. The following optional path is for people who want to use an existing website account and balance.
For a funded signup-free session, use its returned API key. For either credential, send Authorization: Bearer <key> to the API, never as a query parameter. Human website sessions manage account keys; signup-free clients retain their private session secret for recovery. REST base URL: https://api.lyricpatch.com.
Transport: Streamable HTTP
Server URL: https://api.lyricpatch.com/mcp
Authorization: Bearer <api_key from your funded session, or account agent key>
Public MCP metadata discovery: initialize, tools/list and get_service_info.
Fund a signup-free session over REST before using private MCP tools.
Capable hosts can bootstrap and connect the returned key automatically.
Store the key in your client's secret manager.
Never include a real key in a public configuration file.Use an MCP client supporting Streamable HTTP and custom bearer headers. Keep the secret in its secure configuration, not an ordinary chat. Anonymous MCP supports initialization, tool listing and public service information only. Private MCP work requires a valid key; bootstrap creates one without manual website signup.
Use MCP tool discovery for current argument schemas. The brief below describes the full workflow; it does not authorize your agent to choose lyrics, spend money or publish audio without your instructions. The agent supplies exact phrase timing or its own authorized timed transcript for the local matcher.
Use LyricPatch to edit audio I own or have permission to edit.
1. Check your client supports the REST/MCP and wallet workflow.
If I have no key, explain the signup-free $1.99 / 40-credit session.
Confirm my actual age, terms, rights, spending and media-processing
permissions. Never assume these attestations or wallet approval.
Save the session secret securely before the first request and reuse
it on payment retries. Connect only after funding is confirmed.
2. Check available tools, my private balance, permissions and limits.
Upload my MP3 with permission and wait for preparation to finish.
3. Supply exact phrase timestamps, or use your own authorized timed
transcript with LyricPatch's local phrase matcher. LyricPatch does
not transcribe the whole song for this. Ask about ambiguous matches.
Use a 0.1–6-second selection and only my approved words. Optional
LyricPatch transcription covers only a selected clip, with permission.
4. Get the generation quote. Tell me its credit cost and ask before
spending. Do not generate alternate versions automatically.
5. Generate the approved change, then poll its status at the server's
recommended interval. Let me compare original and new audio.
6. Apply only the version I approve. Quote the 5-credit MP3 or WAV
export and ask before preparing it.
7. Download the ready file before the project's 24-hour expiry.
If credits are short, ask before purchasing a pack. Show its price,
network and any wallet fees. Never use another wallet or retry a
payment with a new session or purchase identifier unless I approve it.
Keep session credentials private; a lost session secret has no email recovery.First upload and wait for audio preparation. Draft the replacement, get a quote and approve generation. Keep the resulting work identifier and poll for completion. Applying an approved version selects what enters the finished song; it is not an export. Preparing a new MP3 or WAV is a separate, quoted 5-credit operation.
Start with a 3–4-second phrase and match the original rhythm and approximate syllable count. Supply accurate original words. Optional transcription finds only the selected clip’s words—not the whole song.
A request like “change X to Y” still needs the location of X. The calling agent provides exact timestamps directly, or supplies its own transcript with word-level timing to POST /v1/agent/projects/{project_id}/phrase-matches. LyricPatch matches that supplied text locally and returns candidate selections; this endpoint does not transcribe audio or send a whole song to OpenAI.
The equivalent MCP tool is match_phrase, with project_id, target_phrase and words. It requires the transcribe scope and a prepared project. The JSON body contains target_phrase and words, an array of {text, start_seconds, end_seconds}. Use the prepared project’s actual source timing. The calling client is responsible for any separate transcription, media-sharing permission and processing terms.
# The calling agent supplies its own authorized transcript and timings.
# This example assumes a prepared project containing these time positions.
# LyricPatch matches the supplied words locally; it does not transcribe audio.
curl 'https://api.lyricpatch.com/v1/agent/projects/<project-id>/phrase-matches' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"target_phrase":"welcome home","words":[
{"text":"welcome","start_seconds":30.0,"end_seconds":30.8},
{"text":"home","start_seconds":30.8,"end_seconds":31.4}
]}'
# Read match_status and candidates. Never choose an ambiguous match silently.
# Review the audio and supplied timings; they are not independently verified.
# Use approved, valid start_sample/end_sample in POST /projects/{id}/edits.
# Then save original/replacement lyrics, quote generation and get approval.source: agent_supplied_transcript, a match_status and candidate sample/second ranges. No queue or polling is needed for the matcher.matched is a candidate, not proof the audio says those words. transcript_verified is false, and a candidate’s score measures text similarity, not audio or timing confidence. Review the audio and check selection_valid before generation. For ambiguous, ask which occurrence the owner wants; do not silently choose one.not_found, too_long or too_short need corrected source timing/text or a different approved selection. Do not invent a successful match.The ordinary “Find the words for me” option remains separate: with permission, it sends only a preselected 0.1–6-second clip to OpenAI. It does not locate a phrase across a whole song.
The public LyricPatch connector 1.2.0 includes signup-free sessions, caller-supplied phrase matching and a resumable known-timestamp editing workflow. The CLI saves private work state, separates quote approval from spending, downloads the preview and waits for explicit version/export approval. Python 3.11+ is required.
Copy the install, wallet, preview and export commands for a shell-enabled host, or hear the static Outlet demo. The integration guide explains file transfer, local playback, private credentials and host capability limits. A prompt alone does not install the connector or grant wallet access.
python -m pip install 'git+https://github.com/yaboijbigs/[email protected]'import os
from lyricpatch_agent import LyricPatch
with LyricPatch(os.environ["LYRICPATCH_API_KEY"]) as api:
print(api.account()["credit_balance"])
# Checking the account does not generate audio or spend credits.These authenticated REST paths are relative to /v1/agent. Send your funded-session or account bearer key on these requests. Public session bootstrap and recovery instead use X-LyricPatch-Session, as shown above. Successful REST responses are JSON objects (or a list for projects); deletes return 204. Errors include a machine-readable code. MCP exposes the same operations as tools.
Every mutating project request below needs a unique Idempotency-Key header, 8–128 characters. If a body also includes idempotency_key, it must match the header. Keep both inputs and the same key when recovering a timed-out request. Never reuse a key for a different action.
/accountBalance, legal_version, scopes and current limits.
MCP: get_account
/uploads/presignfilename, size_bytes, content_type: audio/mpeg. Returns signed PUT url, fields and object_key.
MCP: prepare_upload
/projectsobject_key, original_filename, content_type, legal_version and rights_attested: true.
MCP: create_project
/projects/{id}/ingestNo body. Returns preparation job_id; wait for success before editing.
MCP: ingest_project
/projects/{id}Source sample_rate, saved edits, previews and available_exports.
MCP: get_project
/projectsProjects available to this account and key.
MCP: list_projects
/projects/{id}/phrase-matchestarget_phrase and words: [{text, start_seconds, end_seconds}]. Local, unverified transcript matching; no credit charge or transcript persistence.
MCP: match_phrase
/projects/{id}/editsstart_sample, end_sample. Creates a draft; does not generate.
MCP: create_edit
/edits/{id}corrected_lyrics: exact original words; target_lyrics: replacement words.
MCP: update_edit
/projects/{id}/clip-transcriptionsOptional: start_sample, end_sample for only the selected clip.
MCP: transcribe_selection
/clip-transcriptions/{id}Selected-clip status and words.
MCP: get_transcription
/quotesoperation, project_id, max_credits; edit_ids for generate, format for export.
MCP: quote_generation / quote_export
/generationsquote_id, idempotency_key. Spends the approved quote; returns batch/job identifiers.
MCP: generate_changes
/batches/{id}Generation progress and results. Poll at least 3 seconds apart.
MCP: get_batch
/jobs/{id}Preparation, generation or export job status.
MCP: get_job
/generations/{id}/acceptNo body. Apply the owner-approved generated version.
MCP: accept_generation
/exportsquote_id, idempotency_key. Poll job, then get_project for the private file link.
MCP: prepare_export
/batches/{id}Confirm intent; cancel unfinished work. Poll to confirm cancellation.
MCP: cancel_batch
/edits/{id}Confirm intent; remove a saved change.
MCP: delete_edit
/projects/{id}Confirm intent; remove this private project and cancel unfinished work.
MCP: delete_project
Read the prepared source’s sample_rate. Convert seconds to sample positions: round(seconds × sample_rate). At 44,100 Hz, a 0–4-second selection is start_sample: 0, end_sample: 176400. Supply the signed upload response’s fields as headers when sending the raw MP3 bytes to its PUT URL. Do not send your LyricPatch authorization header to the storage URL.
Quotes bind the current selection, lyrics or accepted versions. Read credits and expires_at. A changed or expired quote needs a fresh quote and renewed cost approval. The example below shows the paid steps once the project and edit are ready.
# Assumes an uploaded, prepared project and a draft with saved lyrics.
# All IDs below come from actual earlier API responses.
# Use a fresh idempotency value for each NEW action, keeping it on retries.
curl 'https://api.lyricpatch.com/v1/agent/quotes' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: my-song-generation-quote-001' \
-d '{"operation":"generate","project_id":"<project-id>",
"edit_ids":["<edit-id>"],"max_credits":4}'
# Inspect credits and expires_at. Only continue after user approval.
curl 'https://api.lyricpatch.com/v1/agent/generations' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: my-song-generation-001' \
-d '{"quote_id":"<quote-id>","idempotency_key":"my-song-generation-001"}'
# Read the returned batch ID; poll no faster than once every 3 seconds.
curl 'https://api.lyricpatch.com/v1/agent/batches/<batch-id>' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY"
# After reviewing and accepting a version, quote export separately:
curl 'https://api.lyricpatch.com/v1/agent/quotes' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: my-song-export-quote-001' \
-d '{"operation":"export","project_id":"<project-id>",
"format":"mp3","max_credits":5}'
# After approval, POST /v1/agent/exports with this quote_id and a NEW
# idempotency_key for the export. Keep that key for retries of this export.Account agents and the website share their account’s balance. A signup-free session has its own balance and begins with the $1.99 / 40-credit pack; its funded API key can use the same credit-purchase endpoints below. Generation costs one credit per selected second, rounded up per change. Each successful alternate version costs credits again. A new finished-song MP3 or WAV costs 5 credits to prepare. Re-downloading the same ready file costs nothing extra while the project is available.
| Pack ID | Credits | USD |
|---|---|---|
| credits_40 | 40 | $1.99 |
| credits_100 | 100 | $4.99 |
| credits_400 | 400 | $14.99 |
| credits_1000 | 1000 | $29.99 |
A payments-scoped key can create a credit purchase. x402 uses USDC on Base. An authorized x402-capable wallet client signs the payment; an API key cannot access your wallet or grant wallet-spending permission.
pay_url for an HTTP 402 challenge in PAYMENT-REQUIRED.PAYMENT-SIGNATURE.# Keep the API key in your environment, not the command history.
# This key needs the payments scope.
curl 'https://api.lyricpatch.com/v1/agent/payments' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"pack_id":"credits_40","idempotency_key":"your-unique-purchase-id"}'
# Response: id, status, pay_url, amount_cents, currency, credits.
# Get user approval, then have an x402-capable wallet client handle
# the 402 challenge at pay_url. Plain curl cannot sign a payment.
# After paying, check this SAME purchase instead of creating another:
curl 'https://api.lyricpatch.com/v1/agent/payments/<purchase-id>' \
-H "Authorization: Bearer $LYRICPATCH_API_KEY"Purchase endpoints: POST /v1/agent/payments, GET /v1/agent/payments/{id}, and POST /v1/agent/payments/{id}/pay. Buying credits and approving a generation/export are separate actions. Website checkout remains available through Stripe.
projects:readRead your song projects and their results.
projects:writeUpload, create, edit and delete projects.
generateSpend your credits to generate new versions.
exportSpend your credits to prepare MP3 or WAV files.
transcribeTranscribe only a selected short clip.
paymentsAllow the agent to purchase credits with a separately authorized wallet payment.
Keys act only on their owner identity: the existing account or the isolated signup-free session. A daily credit limit is not a wallet budget: configure wallet authorization separately. Revocation blocks new requests but does not automatically cancel already-started work. Use cancellation when needed.
Agent access lets you create, inspect and revoke keys. Key-management routes at /v1/account/agent-keys require a human’s signed-in session, not an agent key.
For adults 18+. Have the needed permissions for recordings, lyrics and identifiable voices. Agent access does not bypass the Terms, Acceptable Use Policy, or account restrictions.
Email [email protected] with the work or purchase ID for help. Never send session secrets, API secrets, wallet private keys or signed file URLs.
Start a signup-free session