melodai 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- melodai-1.5.0/.gitignore +70 -0
- melodai-1.5.0/LICENSE +21 -0
- melodai-1.5.0/PKG-INFO +99 -0
- melodai-1.5.0/README.md +81 -0
- melodai-1.5.0/melodai/__init__.py +46 -0
- melodai-1.5.0/melodai/api/__init__.py +1 -0
- melodai-1.5.0/melodai/api/account/__init__.py +1 -0
- melodai-1.5.0/melodai/api/account/get_account.py +169 -0
- melodai-1.5.0/melodai/api/albums/__init__.py +1 -0
- melodai-1.5.0/melodai/api/albums/create_album.py +217 -0
- melodai-1.5.0/melodai/api/albums/create_album_art.py +227 -0
- melodai-1.5.0/melodai/api/albums/create_album_zip.py +231 -0
- melodai-1.5.0/melodai/api/albums/delete_album.py +192 -0
- melodai-1.5.0/melodai/api/albums/get_album.py +192 -0
- melodai-1.5.0/melodai/api/albums/get_album_zip.py +200 -0
- melodai-1.5.0/melodai/api/albums/list_albums.py +217 -0
- melodai-1.5.0/melodai/api/albums/set_album_songs.py +240 -0
- melodai-1.5.0/melodai/api/albums/update_album.py +217 -0
- melodai-1.5.0/melodai/api/analysis/__init__.py +1 -0
- melodai-1.5.0/melodai/api/analysis/create_instruments.py +231 -0
- melodai-1.5.0/melodai/api/analysis/detect_chords.py +219 -0
- melodai-1.5.0/melodai/api/analysis/detect_key.py +219 -0
- melodai-1.5.0/melodai/api/analysis/get_instruments.py +196 -0
- melodai-1.5.0/melodai/api/cover_art/__init__.py +1 -0
- melodai-1.5.0/melodai/api/cover_art/create_song_art.py +254 -0
- melodai-1.5.0/melodai/api/lyric_videos/__init__.py +1 -0
- melodai-1.5.0/melodai/api/lyric_videos/create_lyric_video.py +237 -0
- melodai-1.5.0/melodai/api/lyric_videos/create_lyric_video_format.py +241 -0
- melodai-1.5.0/melodai/api/lyric_videos/get_lyric_video.py +192 -0
- melodai-1.5.0/melodai/api/lyric_videos/list_lyric_video_themes.py +165 -0
- melodai-1.5.0/melodai/api/lyric_videos/rerender_lyric_video.py +242 -0
- melodai-1.5.0/melodai/api/lyrics/__init__.py +1 -0
- melodai-1.5.0/melodai/api/lyrics/create_lyrics_timing.py +227 -0
- melodai-1.5.0/melodai/api/lyrics/edit_lyrics.py +221 -0
- melodai-1.5.0/melodai/api/lyrics/generate_lyrics.py +225 -0
- melodai-1.5.0/melodai/api/lyrics/get_lyrics_timing.py +200 -0
- melodai-1.5.0/melodai/api/lyrics/translate_lyrics.py +241 -0
- melodai-1.5.0/melodai/api/mastering/__init__.py +1 -0
- melodai-1.5.0/melodai/api/mastering/create_master.py +248 -0
- melodai-1.5.0/melodai/api/mastering/get_master.py +230 -0
- melodai-1.5.0/melodai/api/remix/__init__.py +1 -0
- melodai-1.5.0/melodai/api/remix/create_remix_master.py +248 -0
- melodai-1.5.0/melodai/api/remix/create_remix_render.py +248 -0
- melodai-1.5.0/melodai/api/remix/create_remix_stems_zip.py +223 -0
- melodai-1.5.0/melodai/api/remix/get_remix.py +200 -0
- melodai-1.5.0/melodai/api/remix/get_remix_grid.py +204 -0
- melodai-1.5.0/melodai/api/remix/get_remix_job.py +200 -0
- melodai-1.5.0/melodai/api/remix/save_remix.py +271 -0
- melodai-1.5.0/melodai/api/remix/suggest_remix.py +264 -0
- melodai-1.5.0/melodai/api/songs/__init__.py +1 -0
- melodai-1.5.0/melodai/api/songs/create_song.py +221 -0
- melodai-1.5.0/melodai/api/songs/delete_song.py +192 -0
- melodai-1.5.0/melodai/api/songs/get_song.py +192 -0
- melodai-1.5.0/melodai/api/songs/list_songs.py +240 -0
- melodai-1.5.0/melodai/api/songs/update_song.py +221 -0
- melodai-1.5.0/melodai/api/stems/__init__.py +1 -0
- melodai-1.5.0/melodai/api/stems/create_stems.py +219 -0
- melodai-1.5.0/melodai/api/stems/get_stems.py +192 -0
- melodai-1.5.0/melodai/api/tabs/__init__.py +1 -0
- melodai-1.5.0/melodai/api/tabs/claim_tab.py +227 -0
- melodai-1.5.0/melodai/api/tabs/create_tab.py +242 -0
- melodai-1.5.0/melodai/api/tabs/get_tab.py +196 -0
- melodai-1.5.0/melodai/api/tabs/list_tabs.py +284 -0
- melodai-1.5.0/melodai/api/versions/__init__.py +1 -0
- melodai-1.5.0/melodai/api/versions/delete_version.py +210 -0
- melodai-1.5.0/melodai/api/versions/extend_song.py +245 -0
- melodai-1.5.0/melodai/api/versions/list_versions.py +196 -0
- melodai-1.5.0/melodai/api/versions/set_default_version.py +233 -0
- melodai-1.5.0/melodai/client.py +280 -0
- melodai-1.5.0/melodai/errors.py +16 -0
- melodai-1.5.0/melodai/models/__init__.py +65 -0
- melodai-1.5.0/melodai/models/album_create_public.py +42 -0
- melodai-1.5.0/melodai/models/album_patch_public.py +74 -0
- melodai-1.5.0/melodai/models/album_songs_public.py +42 -0
- melodai-1.5.0/melodai/models/art_request_public.py +42 -0
- melodai-1.5.0/melodai/models/error_envelope.py +67 -0
- melodai-1.5.0/melodai/models/error_envelope_error.py +80 -0
- melodai-1.5.0/melodai/models/generate_request.py +153 -0
- melodai-1.5.0/melodai/models/list_songs_status_type_0.py +13 -0
- melodai-1.5.0/melodai/models/list_tabs_status_type_0.py +12 -0
- melodai-1.5.0/melodai/models/lyric_video_create_public.py +81 -0
- melodai-1.5.0/melodai/models/lyric_video_create_public_format.py +10 -0
- melodai-1.5.0/melodai/models/lyric_video_format_public.py +44 -0
- melodai-1.5.0/melodai/models/lyric_video_format_public_format.py +10 -0
- melodai-1.5.0/melodai/models/lyric_video_rerender_public.py +89 -0
- melodai-1.5.0/melodai/models/lyric_video_rerender_public_format_type_0.py +10 -0
- melodai-1.5.0/melodai/models/public_extend_request.py +79 -0
- melodai-1.5.0/melodai/models/public_lyrics_edit_request.py +69 -0
- melodai-1.5.0/melodai/models/public_lyrics_generate_request.py +81 -0
- melodai-1.5.0/melodai/models/public_master_request.py +70 -0
- melodai-1.5.0/melodai/models/public_master_request_preset.py +11 -0
- melodai-1.5.0/melodai/models/public_remix_master_request.py +110 -0
- melodai-1.5.0/melodai/models/public_remix_master_request_preset_type_0.py +10 -0
- melodai-1.5.0/melodai/models/public_remix_render_request.py +70 -0
- melodai-1.5.0/melodai/models/public_remix_render_request_format.py +9 -0
- melodai-1.5.0/melodai/models/public_translate_request.py +61 -0
- melodai-1.5.0/melodai/models/song_patch_public.py +74 -0
- melodai-1.5.0/melodai/models/suggest_remix_kind.py +10 -0
- melodai-1.5.0/melodai/models/tab_request_public.py +88 -0
- melodai-1.5.0/melodai/py.typed +0 -0
- melodai-1.5.0/melodai/types.py +54 -0
- melodai-1.5.0/pyproject.toml +35 -0
melodai-1.5.0/.gitignore
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Design handoff (never commit)
|
|
2
|
+
_design/
|
|
3
|
+
design_handoff_melodai/
|
|
4
|
+
|
|
5
|
+
# User PII snapshots for one-off scripts (never commit)
|
|
6
|
+
apps/api/scripts/_*_snapshot.json
|
|
7
|
+
|
|
8
|
+
# Claude Code memory
|
|
9
|
+
.claude/
|
|
10
|
+
|
|
11
|
+
# Dependencies
|
|
12
|
+
node_modules/
|
|
13
|
+
.pnp
|
|
14
|
+
.pnp.js
|
|
15
|
+
|
|
16
|
+
# Build output
|
|
17
|
+
.next/
|
|
18
|
+
out/
|
|
19
|
+
dist/
|
|
20
|
+
build/
|
|
21
|
+
|
|
22
|
+
# Environment files
|
|
23
|
+
.env
|
|
24
|
+
.env.local
|
|
25
|
+
.env.development.local
|
|
26
|
+
.env.test.local
|
|
27
|
+
.env.production.local
|
|
28
|
+
apps/web/.env.local
|
|
29
|
+
apps/api/.env
|
|
30
|
+
apps/api/prod.env
|
|
31
|
+
prod.env
|
|
32
|
+
|
|
33
|
+
# Python
|
|
34
|
+
__pycache__/
|
|
35
|
+
*.py[cod]
|
|
36
|
+
*$py.class
|
|
37
|
+
*.egg-info/
|
|
38
|
+
.venv/
|
|
39
|
+
venv/
|
|
40
|
+
env/
|
|
41
|
+
|
|
42
|
+
# OS
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
45
|
+
|
|
46
|
+
# IDEs
|
|
47
|
+
.vscode/
|
|
48
|
+
.idea/
|
|
49
|
+
*.swp
|
|
50
|
+
*.swo
|
|
51
|
+
|
|
52
|
+
# Logs
|
|
53
|
+
npm-debug.log*
|
|
54
|
+
yarn-debug.log*
|
|
55
|
+
yarn-error.log*
|
|
56
|
+
*.log
|
|
57
|
+
|
|
58
|
+
# Supabase
|
|
59
|
+
.supabase/
|
|
60
|
+
supabase/.temp/
|
|
61
|
+
apps/web/supabase/
|
|
62
|
+
.gstack/
|
|
63
|
+
apps/api/.venv-transcription/
|
|
64
|
+
.mcp.json
|
|
65
|
+
|
|
66
|
+
# Local dev services (Memurai/Redis, MT3 transcription checkpoints)
|
|
67
|
+
dump.rdb
|
|
68
|
+
memurai-log.txt
|
|
69
|
+
apps/api/.mt3_checkpoints/
|
|
70
|
+
apps/api/start_mt3_services.vbs
|
melodai-1.5.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MelodAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
melodai-1.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: melodai
|
|
3
|
+
Version: 1.5.0
|
|
4
|
+
Summary: Official Python client for the MelodAI Public API: generate songs, split stems, transcribe tabs.
|
|
5
|
+
Project-URL: Homepage, https://melodai.ai
|
|
6
|
+
Project-URL: Documentation, https://melodai.ai/docs/api
|
|
7
|
+
Author-email: MelodAI <hello@melodai.ai>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai,api,melodai,music,sdk,song-generation,stems,tabs
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: attrs>=22.2.0
|
|
16
|
+
Requires-Dist: httpx2<3,>=2.13.1
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# melodai
|
|
20
|
+
|
|
21
|
+
The official Python client for the [MelodAI Public API](https://melodai.ai/docs/api): generate songs,
|
|
22
|
+
split stems, transcribe tabs, master, remix and more.
|
|
23
|
+
|
|
24
|
+
It is generated from the public OpenAPI spec, so every endpoint in the docs has a module here
|
|
25
|
+
(`melodai.api.songs.create_song`, `get_song`, `melodai.api.stems.create_stems`,
|
|
26
|
+
`melodai.api.tabs.create_tab`, ...), each with `sync`, `sync_detailed`, `asyncio` and
|
|
27
|
+
`asyncio_detailed` functions. Python 3.11+, fully typed.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install melodai
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Authenticate
|
|
36
|
+
|
|
37
|
+
Create an API key at <https://melodai.ai/app/api-keys> (Pro, Creator, or any account that has bought
|
|
38
|
+
credits). It is sent as the `X-API-Key` header on every call.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import os
|
|
42
|
+
from melodai import create_client
|
|
43
|
+
|
|
44
|
+
client = create_client(api_key=os.environ["MELODAI_API_KEY"])
|
|
45
|
+
# base URL defaults to https://api.melodai.ai/api/public/v1; pass base_url= to override
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Generate a song and wait for it
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import os, time, uuid
|
|
52
|
+
from melodai import create_client
|
|
53
|
+
from melodai.api.songs import create_song, get_song
|
|
54
|
+
from melodai.models import ErrorEnvelope, GenerateRequest
|
|
55
|
+
|
|
56
|
+
client = create_client(api_key=os.environ["MELODAI_API_KEY"])
|
|
57
|
+
|
|
58
|
+
created = create_song.sync(
|
|
59
|
+
client=client,
|
|
60
|
+
body=GenerateRequest(prompt="warm lo-fi hip hop beat for studying, vinyl crackle"),
|
|
61
|
+
# A retry with the same key and body never charges twice (stored 24 h).
|
|
62
|
+
idempotency_key=str(uuid.uuid4()),
|
|
63
|
+
)
|
|
64
|
+
if isinstance(created, ErrorEnvelope):
|
|
65
|
+
raise RuntimeError(f"{created.error.code}: {created.error.message}")
|
|
66
|
+
|
|
67
|
+
song_id = created["song_id"]
|
|
68
|
+
while True:
|
|
69
|
+
time.sleep(5)
|
|
70
|
+
song = get_song.sync(client=client, song_id=song_id)
|
|
71
|
+
if isinstance(song, ErrorEnvelope):
|
|
72
|
+
raise RuntimeError(song.error.message)
|
|
73
|
+
if song["status"] not in ("queued", "processing"):
|
|
74
|
+
break
|
|
75
|
+
|
|
76
|
+
print(song["status"], song.get("audio_url"))
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Use `asyncio` / `asyncio_detailed` for async code (`async with client:`), and `sync_detailed` when you
|
|
80
|
+
need the status code or headers (`Retry-After` on a 429).
|
|
81
|
+
|
|
82
|
+
## Errors
|
|
83
|
+
|
|
84
|
+
Every error body uses one envelope, parsed into `ErrorEnvelope`:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{ "error": { "code": "insufficient_credits", "message": "...", "docs_url": "https://melodai.ai/docs/api#errors-insufficient_credits" } }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Branch on `error.code` (stable) rather than the message. Pass `raise_on_unexpected_status=True` to
|
|
91
|
+
`create_client` to raise on a status the spec doesn't document.
|
|
92
|
+
|
|
93
|
+
## Links
|
|
94
|
+
|
|
95
|
+
- Docs and every error code: <https://melodai.ai/docs/api>
|
|
96
|
+
- OpenAPI spec: <https://melodai.ai/api/openapi.json>
|
|
97
|
+
- TypeScript SDK: `npm install melodai`
|
|
98
|
+
|
|
99
|
+
MIT licensed.
|
melodai-1.5.0/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# melodai
|
|
2
|
+
|
|
3
|
+
The official Python client for the [MelodAI Public API](https://melodai.ai/docs/api): generate songs,
|
|
4
|
+
split stems, transcribe tabs, master, remix and more.
|
|
5
|
+
|
|
6
|
+
It is generated from the public OpenAPI spec, so every endpoint in the docs has a module here
|
|
7
|
+
(`melodai.api.songs.create_song`, `get_song`, `melodai.api.stems.create_stems`,
|
|
8
|
+
`melodai.api.tabs.create_tab`, ...), each with `sync`, `sync_detailed`, `asyncio` and
|
|
9
|
+
`asyncio_detailed` functions. Python 3.11+, fully typed.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install melodai
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Authenticate
|
|
18
|
+
|
|
19
|
+
Create an API key at <https://melodai.ai/app/api-keys> (Pro, Creator, or any account that has bought
|
|
20
|
+
credits). It is sent as the `X-API-Key` header on every call.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import os
|
|
24
|
+
from melodai import create_client
|
|
25
|
+
|
|
26
|
+
client = create_client(api_key=os.environ["MELODAI_API_KEY"])
|
|
27
|
+
# base URL defaults to https://api.melodai.ai/api/public/v1; pass base_url= to override
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Generate a song and wait for it
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import os, time, uuid
|
|
34
|
+
from melodai import create_client
|
|
35
|
+
from melodai.api.songs import create_song, get_song
|
|
36
|
+
from melodai.models import ErrorEnvelope, GenerateRequest
|
|
37
|
+
|
|
38
|
+
client = create_client(api_key=os.environ["MELODAI_API_KEY"])
|
|
39
|
+
|
|
40
|
+
created = create_song.sync(
|
|
41
|
+
client=client,
|
|
42
|
+
body=GenerateRequest(prompt="warm lo-fi hip hop beat for studying, vinyl crackle"),
|
|
43
|
+
# A retry with the same key and body never charges twice (stored 24 h).
|
|
44
|
+
idempotency_key=str(uuid.uuid4()),
|
|
45
|
+
)
|
|
46
|
+
if isinstance(created, ErrorEnvelope):
|
|
47
|
+
raise RuntimeError(f"{created.error.code}: {created.error.message}")
|
|
48
|
+
|
|
49
|
+
song_id = created["song_id"]
|
|
50
|
+
while True:
|
|
51
|
+
time.sleep(5)
|
|
52
|
+
song = get_song.sync(client=client, song_id=song_id)
|
|
53
|
+
if isinstance(song, ErrorEnvelope):
|
|
54
|
+
raise RuntimeError(song.error.message)
|
|
55
|
+
if song["status"] not in ("queued", "processing"):
|
|
56
|
+
break
|
|
57
|
+
|
|
58
|
+
print(song["status"], song.get("audio_url"))
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use `asyncio` / `asyncio_detailed` for async code (`async with client:`), and `sync_detailed` when you
|
|
62
|
+
need the status code or headers (`Retry-After` on a 429).
|
|
63
|
+
|
|
64
|
+
## Errors
|
|
65
|
+
|
|
66
|
+
Every error body uses one envelope, parsed into `ErrorEnvelope`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{ "error": { "code": "insufficient_credits", "message": "...", "docs_url": "https://melodai.ai/docs/api#errors-insufficient_credits" } }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Branch on `error.code` (stable) rather than the message. Pass `raise_on_unexpected_status=True` to
|
|
73
|
+
`create_client` to raise on a status the spec doesn't document.
|
|
74
|
+
|
|
75
|
+
## Links
|
|
76
|
+
|
|
77
|
+
- Docs and every error code: <https://melodai.ai/docs/api>
|
|
78
|
+
- OpenAPI spec: <https://melodai.ai/api/openapi.json>
|
|
79
|
+
- TypeScript SDK: `npm install melodai`
|
|
80
|
+
|
|
81
|
+
MIT licensed.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Official Python client for the MelodAI Public API.
|
|
2
|
+
|
|
3
|
+
Generated from the public OpenAPI spec (sdks/generate.py); this template
|
|
4
|
+
(sdks/python/templates/package_init.py.jinja) only adds ``create_client``.
|
|
5
|
+
|
|
6
|
+
from melodai import create_client
|
|
7
|
+
from melodai.api.songs import create_song, get_song
|
|
8
|
+
from melodai.models import GenerateRequest
|
|
9
|
+
|
|
10
|
+
client = create_client(api_key="mk_live_...")
|
|
11
|
+
created = create_song.sync(client=client, body=GenerateRequest(prompt="lo-fi beat"))
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .client import AuthenticatedClient, Client
|
|
15
|
+
|
|
16
|
+
DEFAULT_BASE_URL = "https://api.melodai.ai/api/public/v1"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_client(
|
|
20
|
+
api_key: str, base_url: str = DEFAULT_BASE_URL, **kwargs
|
|
21
|
+
) -> AuthenticatedClient:
|
|
22
|
+
"""A client that sends ``api_key`` as the ``X-API-Key`` header on every call.
|
|
23
|
+
|
|
24
|
+
Create a key at https://melodai.ai/app/api-keys. Extra keyword arguments
|
|
25
|
+
(``timeout``, ``headers``, ``raise_on_unexpected_status``, ...) are passed
|
|
26
|
+
to :class:`AuthenticatedClient`.
|
|
27
|
+
"""
|
|
28
|
+
if not api_key:
|
|
29
|
+
raise ValueError(
|
|
30
|
+
"melodai: api_key is required (create one at https://melodai.ai/app/api-keys)"
|
|
31
|
+
)
|
|
32
|
+
return AuthenticatedClient(
|
|
33
|
+
base_url=base_url,
|
|
34
|
+
token=api_key,
|
|
35
|
+
prefix="",
|
|
36
|
+
auth_header_name="X-API-Key",
|
|
37
|
+
**kwargs,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
__all__ = (
|
|
42
|
+
"DEFAULT_BASE_URL",
|
|
43
|
+
"AuthenticatedClient",
|
|
44
|
+
"Client",
|
|
45
|
+
"create_client",
|
|
46
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains methods for accessing the API"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx2
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.error_envelope import ErrorEnvelope
|
|
9
|
+
from ...types import Response
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _get_kwargs() -> dict[str, Any]:
|
|
13
|
+
|
|
14
|
+
_kwargs: dict[str, Any] = {
|
|
15
|
+
"method": "get",
|
|
16
|
+
"url": "/me",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return _kwargs
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _parse_response(
|
|
23
|
+
*, client: AuthenticatedClient | Client, response: httpx2.Response
|
|
24
|
+
) -> Any | ErrorEnvelope | None:
|
|
25
|
+
if response.status_code == 200:
|
|
26
|
+
response_200 = response.json()
|
|
27
|
+
return response_200
|
|
28
|
+
|
|
29
|
+
if response.status_code == 401:
|
|
30
|
+
response_401 = ErrorEnvelope.from_dict(response.json())
|
|
31
|
+
|
|
32
|
+
return response_401
|
|
33
|
+
|
|
34
|
+
if response.status_code == 403:
|
|
35
|
+
response_403 = ErrorEnvelope.from_dict(response.json())
|
|
36
|
+
|
|
37
|
+
return response_403
|
|
38
|
+
|
|
39
|
+
if response.status_code == 404:
|
|
40
|
+
response_404 = ErrorEnvelope.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_404
|
|
43
|
+
|
|
44
|
+
if response.status_code == 422:
|
|
45
|
+
response_422 = ErrorEnvelope.from_dict(response.json())
|
|
46
|
+
|
|
47
|
+
return response_422
|
|
48
|
+
|
|
49
|
+
if response.status_code == 429:
|
|
50
|
+
response_429 = ErrorEnvelope.from_dict(response.json())
|
|
51
|
+
|
|
52
|
+
return response_429
|
|
53
|
+
|
|
54
|
+
if response.status_code == 503:
|
|
55
|
+
response_503 = ErrorEnvelope.from_dict(response.json())
|
|
56
|
+
|
|
57
|
+
return response_503
|
|
58
|
+
|
|
59
|
+
if client.raise_on_unexpected_status:
|
|
60
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
61
|
+
else:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _build_response(
|
|
66
|
+
*, client: AuthenticatedClient | Client, response: httpx2.Response
|
|
67
|
+
) -> Response[Any | ErrorEnvelope]:
|
|
68
|
+
return Response(
|
|
69
|
+
status_code=HTTPStatus(response.status_code),
|
|
70
|
+
content=response.content,
|
|
71
|
+
headers=response.headers,
|
|
72
|
+
parsed=_parse_response(client=client, response=response),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def sync_detailed(
|
|
77
|
+
*,
|
|
78
|
+
client: AuthenticatedClient | Client,
|
|
79
|
+
) -> Response[Any | ErrorEnvelope]:
|
|
80
|
+
"""Get your account
|
|
81
|
+
|
|
82
|
+
Plan, API-spendable credits (plan + purchased), tab credits, rate tier, and the key's daily spend
|
|
83
|
+
cap with what it has spent today (UTC). Free.
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
87
|
+
httpx2.TimeoutException: If the request takes longer than Client.timeout.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Response[Any | ErrorEnvelope]
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
kwargs = _get_kwargs()
|
|
94
|
+
|
|
95
|
+
response = client.get_httpx_client().request(
|
|
96
|
+
**kwargs,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
return _build_response(client=client, response=response)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def sync(
|
|
103
|
+
*,
|
|
104
|
+
client: AuthenticatedClient | Client,
|
|
105
|
+
) -> Any | ErrorEnvelope | None:
|
|
106
|
+
"""Get your account
|
|
107
|
+
|
|
108
|
+
Plan, API-spendable credits (plan + purchased), tab credits, rate tier, and the key's daily spend
|
|
109
|
+
cap with what it has spent today (UTC). Free.
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
113
|
+
httpx2.TimeoutException: If the request takes longer than Client.timeout.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Any | ErrorEnvelope
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
return sync_detailed(
|
|
120
|
+
client=client,
|
|
121
|
+
).parsed
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async def asyncio_detailed(
|
|
125
|
+
*,
|
|
126
|
+
client: AuthenticatedClient | Client,
|
|
127
|
+
) -> Response[Any | ErrorEnvelope]:
|
|
128
|
+
"""Get your account
|
|
129
|
+
|
|
130
|
+
Plan, API-spendable credits (plan + purchased), tab credits, rate tier, and the key's daily spend
|
|
131
|
+
cap with what it has spent today (UTC). Free.
|
|
132
|
+
|
|
133
|
+
Raises:
|
|
134
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
135
|
+
httpx2.TimeoutException: If the request takes longer than Client.timeout.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
Response[Any | ErrorEnvelope]
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
kwargs = _get_kwargs()
|
|
142
|
+
|
|
143
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
144
|
+
|
|
145
|
+
return _build_response(client=client, response=response)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
async def asyncio(
|
|
149
|
+
*,
|
|
150
|
+
client: AuthenticatedClient | Client,
|
|
151
|
+
) -> Any | ErrorEnvelope | None:
|
|
152
|
+
"""Get your account
|
|
153
|
+
|
|
154
|
+
Plan, API-spendable credits (plan + purchased), tab credits, rate tier, and the key's daily spend
|
|
155
|
+
cap with what it has spent today (UTC). Free.
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
159
|
+
httpx2.TimeoutException: If the request takes longer than Client.timeout.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Any | ErrorEnvelope
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
await asyncio_detailed(
|
|
167
|
+
client=client,
|
|
168
|
+
)
|
|
169
|
+
).parsed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|