diff --git a/Cargo.lock b/Cargo.lock index 3cf1890..6bde39e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -352,9 +352,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "av-scenechange" @@ -687,9 +687,9 @@ dependencies = [ [[package]] name = "brotli" -version = "8.0.2" +version = "8.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +checksum = "8119e4516436f5708bbc474a9d395bf12f1b5395e93a92a56e647ac3388c8610" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -698,9 +698,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "5.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +checksum = "5962523e1b92ce1b5e793d9169b9943eece10d39f62550bc04bb605d75b94924" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -717,15 +717,15 @@ dependencies = [ [[package]] name = "built" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" +checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "byte-unit" @@ -1446,9 +1446,9 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", @@ -2304,9 +2304,9 @@ dependencies = [ [[package]] name = "http" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +checksum = "8be7462df143984c4598a256ef469b251d7d7f9e271135073e78fc535414f3d0" dependencies = [ "bytes", "itoa", @@ -2358,9 +2358,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +checksum = "eb92f162bf56536459fc83c79b974bb12837acfed43d6bc370a7916d0ae15ecc" dependencies = [ "atomic-waker", "bytes", @@ -2830,9 +2830,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.98" +version = "0.3.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" +checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11" dependencies = [ "cfg-if", "futures-util", @@ -2914,18 +2914,18 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libmimalloc-sys" -version = "0.1.48" +version = "0.1.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2892ae4ea6fa2cb7acb0e236a6880d39523239cd9089de71d220910ccc806790" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" dependencies = [ "cc", ] [[package]] name = "libredox" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" dependencies = [ "libc", ] @@ -2964,9 +2964,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5" [[package]] name = "loop9" @@ -3017,9 +3017,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" [[package]] name = "merlin" @@ -3035,9 +3035,9 @@ dependencies = [ [[package]] name = "mimalloc" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebca48a43116bc25f18a61360f1be98412f50cc218f5e52c823086b999a4a21a" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" dependencies = [ "libmimalloc-sys", ] @@ -4263,9 +4263,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e0021ea2c22aed41653bc7e1419abb2c97e038ff2c33d0e1309e49a97deec0" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" dependencies = [ "base64", "bytes", @@ -4972,9 +4972,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", @@ -5677,9 +5677,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.11+spec-1.1.0" +version = "0.25.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b59c4d22ed448339746c59b905d24568fcbb3ab65a500494f7b8c3e97739f2b" +checksum = "d2153edc6955a6c354fad8f5efd38b6a8769bdccf9fe50f8e1329f81b0baa5d7" dependencies = [ "indexmap 2.14.0", "toml_datetime", @@ -6185,9 +6185,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" +checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409" dependencies = [ "cfg-if", "once_cell", @@ -6198,9 +6198,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.71" +version = "0.4.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8" +checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f" dependencies = [ "js-sys", "wasm-bindgen", @@ -6208,9 +6208,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" +checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6218,9 +6218,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" +checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e" dependencies = [ "bumpalo", "proc-macro2", @@ -6231,9 +6231,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.121" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" +checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437" dependencies = [ "unicode-ident", ] @@ -6287,9 +6287,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.98" +version = "0.3.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b572dff8bcf38bad0fa19729c89bb5748b2b9b1d8be70cf90df697e3a8f32aa" +checksum = "6d621441cfc37b84979402712047321980c178f299193a3589d05b99e8763436" dependencies = [ "js-sys", "wasm-bindgen", @@ -6883,18 +6883,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "bce33a6288fa3f072a8c2c7d0f2fdbb90e28298f0135c1f99b96c3db2efcc60b" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "8fd425244944f4ab65ccff928e7323354c5a018c75838362fdce749dfad2ee1e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 03fed7b..43cc378 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ async-trait = "0.1.89" quinn = { version = "0.11.9", features = ["rustls", "runtime-tokio", "log"] } h3 = { version = "0.0.8", features = ["tracing"] } h3-quinn = { version = "0.0.10" } -http = "1.4.0" +http = "1.4.1" backon = "1.6.0" openraft = { version = "0.9.24", features = ["storage-v2", "serde"] } tokio-postgres-rustls = "0.14.0" @@ -52,7 +52,7 @@ rustls-platform-verifier = "0.7.0" toml = "1.1.2" uuid = { version = "1.23.0", features = ["v4", "serde"] } serde = { version = "1.0.228", features = ["derive"] } -serde_json = "1.0.149" +serde_json = "1.0.150" rmp-serde = "1.3.1" anyhow = "1.0.102" bytes = "1.11.1" @@ -68,7 +68,7 @@ bs58 = "0.5.1" prometheus = "0.14.0" blake3 = "1.8.5" moka = { version = "0.12.15", features = ["sync"] } -mimalloc = { version = "0.1.51", default-features = false } +mimalloc = { version = "0.1.52", default-features = false } regex = "1.12.3" image = "0.25.10" chrono = { version = "0.4", features = ["serde", "clock"] } @@ -84,7 +84,7 @@ http-body-util = "0.1.3" futures-lite = { version = "2.6.1", default-features = false, features = [ "std", ] } -reqwest = { version = "0.13.3", default-features = false, features = ["json", "multipart"] } +reqwest = { version = "0.13.4", default-features = false, features = ["json", "multipart"] } testcontainers-modules = { version = "0.15.0", features = ["postgres"] } [features] diff --git a/docs/api/client_api.md b/docs/api/client_api.md index 7eb0837..6900ba7 100644 --- a/docs/api/client_api.md +++ b/docs/api/client_api.md @@ -5,11 +5,13 @@ This page gives the minimal setup and where to find runnable examples. ## Quick start 1) Get your API key from your `gen.404.xyz/account` page after signing in. -2) Pick the closest gateway base URL: +2) Pick a gateway base URL. The GeoDNS endpoint routes to the closest healthy region: + +- **GeoDNS**: `https://api.dns.404.xyz` +- **EU**: `https://api-eu.404.xyz` +- **US East**: `https://api-us-east.404.xyz` +- **US West**: `https://api-us-west.404.xyz` -- **EU**: `https://gateway-eu.404.xyz:4443` -- **US-EAST**: `https://gateway-us-east.404.xyz:4443` -- **US-WEST**: `https://gateway-us-west.404.xyz:4443` 3) Send requests with the `x-api-key` header. ## Two pipelines diff --git a/docs/api/console.md b/docs/api/console.md index ca843c3..9344830 100644 --- a/docs/api/console.md +++ b/docs/api/console.md @@ -1,17 +1,24 @@ # 404.xyz Gateway Console Examples -This page contains curl examples for the gateway. Replace `{REGION}` and +This page contains curl examples for the gateway. Replace `{BASE_URL}` and `{YOUR-API-KEY}` with your values. Optional: include `model` in `/add_task` to select output format. For `404-3dgs`, `/get_result` returns SPZ by default (PLY with `compress=0`). For `404-mesh`, `/get_result` returns GLB. +## Server domains + +- **GeoDNS**: `https://api.dns.404.xyz` (routes to the closest healthy region) +- **EU**: `https://api-eu.404.xyz` +- **US East**: `https://api-us-east.404.xyz` +- **US West**: `https://api-us-west.404.xyz` + ## Text to 3D (console) Note: `model` is only sent to `/add_task`, not `/get_status` or `/get_result`. ### 1. Add task ```console -curl --http3 -X POST "https://{REGION}:4443/add_task" \ +curl --http3 -X POST "{BASE_URL}/add_task" \ -H "content-type: application/json" \ -H "x-api-key: {YOUR-API-KEY}" \ -d '{"prompt": "mechanic robot"}' @@ -19,7 +26,7 @@ curl --http3 -X POST "https://{REGION}:4443/add_task" \ Optional: add `model` to select output format (**Note: `404-mesh` for text-to-3d will be available later**). Optional: add `seed` for reproducible outputs. ```console -curl --http3 -X POST "https://{REGION}:4443/add_task" \ +curl --http3 -X POST "{BASE_URL}/add_task" \ -H "content-type: application/json" \ -H "x-api-key: {YOUR-API-KEY}" \ -d '{"prompt": "mechanic robot", "model": "404-3dgs", "seed": 12345}' @@ -28,7 +35,7 @@ curl --http3 -X POST "https://{REGION}:4443/add_task" \ ### 2. Get task status Note: use the task ID returned from `/add_task`. ```console -curl --http3 "https://{REGION}:4443/get_status?id=123e4567-e89b-12d3-a456-426614174000" \ +curl --http3 "{BASE_URL}/get_status?id=123e4567-e89b-12d3-a456-426614174000" \ -H "x-api-key: {YOUR-API-KEY}" ``` @@ -37,7 +44,7 @@ Note: use the task ID returned from `/add_task`. To unpack SPZ, use C++/Python bindings from https://github.com/404-Repo/spz or the web interface at https://spz.404.xyz/ ```console -curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ +curl --http3 "{BASE_URL}/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ -H "x-api-key: {YOUR-API-KEY}" \ -o result.spz ``` @@ -45,7 +52,7 @@ curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614 ### 4. Get result (PLY, uncompressed) Note: use the task ID returned from `/add_task`. Use `compress=0`. ```console -curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000&compress=0" \ +curl --http3 "{BASE_URL}/get_result?id=123e4567-e89b-12d3-a456-426614174000&compress=0" \ -H "x-api-key: {YOUR-API-KEY}" \ -o model.ply ``` @@ -56,14 +63,14 @@ Note: `model` is only sent to `/add_task`, not `/get_result`. ### 1. Add 2D to 3D task Important: send only an image for 2D to 3D tasks. Do not send a prompt. ```console -curl --http3 -X POST "https://{REGION}:4443/add_task" \ +curl --http3 -X POST "{BASE_URL}/add_task" \ -F "image=@image.jpg" \ -H "x-api-key: {YOUR-API-KEY}" ``` Optional: add `model` to select output format (example uses `404-mesh`). Optional: add `seed` for reproducible outputs. ```console -curl --http3 -X POST "https://{REGION}:4443/add_task" \ +curl --http3 -X POST "{BASE_URL}/add_task" \ -F "image=@image.jpg" \ -F "model=404-mesh" \ -F "seed=12345" \ @@ -75,7 +82,7 @@ Note: use the task ID returned from `/add_task`. To unpack SPZ, use C++/Python bindings from https://github.com/404-Repo/spz or the web interface at https://spz.404.xyz/ ```console -curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ +curl --http3 "{BASE_URL}/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ -H "x-api-key: {YOUR-API-KEY}" \ -o result.spz ``` @@ -83,7 +90,7 @@ curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614 ### 3. Get result (PLY, uncompressed) Note: use the task ID returned from `/add_task`. Use `compress=0`. ```console -curl --http3 "https://{REGION}:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000&compress=0" \ +curl --http3 "{BASE_URL}/get_result?id=123e4567-e89b-12d3-a456-426614174000&compress=0" \ -H "x-api-key: {YOUR-API-KEY}" \ -o model.ply ``` diff --git a/docs/api/python.md b/docs/api/python.md index 17f30e2..5ddadaf 100644 --- a/docs/api/python.md +++ b/docs/api/python.md @@ -1,11 +1,18 @@ # 404.xyz Gateway Python Examples -This page contains Python examples for the gateway. Replace `{REGION}` and +This page contains Python examples for the gateway. Replace `{BASE_URL}` and `{YOUR-API-KEY}` with your values. Optional: include `model` in `/add_task` to select output format. For `404-3dgs`, `/get_result` returns SPZ by default (PLY with `compress=0`). For `404-mesh`, `/get_result` returns GLB. +## Server domains + +- **GeoDNS**: `https://api.dns.404.xyz` (routes to the closest healthy region) +- **EU**: `https://api-eu.404.xyz` +- **US East**: `https://api-us-east.404.xyz` +- **US West**: `https://api-us-west.404.xyz` + ## Text to 3D (Python) Note: `model` is only sent to `/add_task`, not `/get_status` or `/get_result`. @@ -13,10 +20,10 @@ Note: `model` is only sent to `/add_task`, not `/get_status` or `/get_result`. ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" -url = f"https://{region}:4443/add_task" +url = f"{base_url}/add_task" headers = {"content-type": "application/json", "x-api-key": api_key} data = {"prompt": "mechanic robot", "model": "404-3dgs", "seed": 12345} # Optional model, optional seed @@ -29,10 +36,10 @@ with httpx.Client(http2=True) as client: ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" -url = f"https://{region}:4443/get_status" +url = f"{base_url}/get_status" headers = {"x-api-key": api_key} params = {"id": "bc2e40a1-1e51-4a09-8a58-c42b93b573b2"} @@ -48,11 +55,11 @@ or the web interface at https://spz.404.xyz/ ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" task_id = "123e4567-e89b-12d3-a456-426614174000" -url = f"https://{region}:4443/get_result" +url = f"{base_url}/get_result" params = {"id": task_id} headers = {"x-api-key": api_key} @@ -68,8 +75,7 @@ import httpx import time API_KEY = "API_KEY" -GATEWAY = "gateway-eu.404.xyz" -BASE_URL = f"https://{GATEWAY}:4443" +BASE_URL = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed # Choose output format: "spz" (default, compressed) or "ply" (compress=0) OUTPUT_FORMAT = "spz" # or "ply" @@ -104,10 +110,10 @@ Note: `model` is only sent to `/add_task`, not `/get_result`. ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" -url = f"https://{region}:4443/add_task" +url = f"{base_url}/add_task" headers = {"x-api-key": api_key} with httpx.Client(http2=True) as client: @@ -125,11 +131,11 @@ or the web interface at https://spz.404.xyz/ ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" task_id = "123e4567-e89b-12d3-a456-426614174000" -url = f"https://{region}:4443/get_result" +url = f"{base_url}/get_result" params = {"id": task_id} headers = {"x-api-key": api_key} @@ -143,11 +149,11 @@ with httpx.Client(http2=True) as client: ```python import httpx -region = "gateway-eu.404.xyz" # Replace with your region +base_url = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed api_key = "{YOUR-API-KEY}" task_id = "123e4567-e89b-12d3-a456-426614174000" -url = f"https://{region}:4443/get_result" +url = f"{base_url}/get_result" params = {"id": task_id, "compress": "0"} headers = {"x-api-key": api_key} @@ -163,8 +169,7 @@ import httpx import time API_KEY = "{YOUR-API-KEY}" -GATEWAY = "gateway-eu.404.xyz" -BASE_URL = f"https://{GATEWAY}:4443" +BASE_URL = "https://api.dns.404.xyz" # GeoDNS; replace with a regional URL if needed # Choose output format: "spz" (default, compressed) or "ply" (compress=0) OUTPUT_FORMAT = "ply" # or "spz" diff --git a/docs/api/typescript.md b/docs/api/typescript.md index 479c5d7..b14647b 100644 --- a/docs/api/typescript.md +++ b/docs/api/typescript.md @@ -1,20 +1,27 @@ # 404.xyz Gateway TypeScript Examples (Bun/Node.js) These examples work with Bun and Node.js 18+ (which includes `fetch`). -Replace `{REGION}` and `{YOUR-API-KEY}` with your values. +Replace `{BASE_URL}` and `{YOUR-API-KEY}` with your values. Optional: include `model` in `/add_task` to select output format. For `404-3dgs`, `/get_result` returns SPZ by default (PLY with `compress=0`). For `404-mesh`, `/get_result` returns GLB. +## Server domains + +- **GeoDNS**: `https://api.dns.404.xyz` (routes to the closest healthy region) +- **EU**: `https://api-eu.404.xyz` +- **US East**: `https://api-us-east.404.xyz` +- **US West**: `https://api-us-west.404.xyz` + ## Text to 3D (TypeScript) Note: `model` is only sent to `/add_task`, not `/get_status` or `/get_result`. ### 1. Add task ```ts -const region = "gateway-eu.404.xyz"; // Replace with your region +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; -const res = await fetch(`https://${region}:4443/add_task`, { +const res = await fetch(`${baseUrl}/add_task`, { method: "POST", headers: { "content-type": "application/json", @@ -29,11 +36,11 @@ console.log(json); ### 2. Get task status ```ts -const region = "gateway-eu.404.xyz"; +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; const taskId = "bc2e40a1-1e51-4a09-8a58-c42b93b573b2"; -const url = new URL(`https://${region}:4443/get_status`); +const url = new URL(`${baseUrl}/get_status`); url.searchParams.set("id", taskId); const res = await fetch(url, { @@ -45,11 +52,11 @@ console.log(res.status, await res.text()); ### 3. Get result (SPZ, default) ```ts -const region = "gateway-eu.404.xyz"; +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; const taskId = "123e4567-e89b-12d3-a456-426614174000"; -const url = new URL(`https://${region}:4443/get_result`); +const url = new URL(`${baseUrl}/get_result`); url.searchParams.set("id", taskId); const res = await fetch(url, { headers: { "x-api-key": apiKey } }); @@ -62,8 +69,7 @@ await Bun.write("result.spz", buf); // Bun ### Complete example with selectable output (SPZ or PLY) ```ts const API_KEY = "{YOUR-API-KEY}"; -const GATEWAY = "gateway-eu.404.xyz"; -const BASE_URL = `https://${GATEWAY}:4443`; +const BASE_URL = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed // Choose output format: "spz" (default, compressed) or "ply" (compress=0) const OUTPUT_FORMAT = "spz"; // or "ply" @@ -106,7 +112,7 @@ Note: `model` is only sent to `/add_task`, not `/get_result`. ### 1. Add 2D to 3D task ```ts -const region = "gateway-eu.404.xyz"; +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; const form = new FormData(); @@ -117,7 +123,7 @@ form.append("seed", "12345"); // Optional seed for reproducibility // import fs from "node:fs"; // form.append("image", new Blob([fs.readFileSync("input_2d_image.jpg")]), "input_2d_image.jpg"); -const res = await fetch(`https://${region}:4443/add_task`, { +const res = await fetch(`${baseUrl}/add_task`, { method: "POST", headers: { "x-api-key": apiKey }, body: form, @@ -128,11 +134,11 @@ console.log(await res.json()); ### 2. Get result (SPZ, default) ```ts -const region = "gateway-eu.404.xyz"; +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; const taskId = "123e4567-e89b-12d3-a456-426614174000"; -const url = new URL(`https://${region}:4443/get_result`); +const url = new URL(`${baseUrl}/get_result`); url.searchParams.set("id", taskId); const res = await fetch(url, { headers: { "x-api-key": apiKey } }); @@ -144,11 +150,11 @@ await Bun.write("result.spz", buf); // Bun ### 3. Get result (PLY) ```ts -const region = "gateway-eu.404.xyz"; +const baseUrl = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed const apiKey = "{YOUR-API-KEY}"; const taskId = "123e4567-e89b-12d3-a456-426614174000"; -const url = new URL(`https://${region}:4443/get_result`); +const url = new URL(`${baseUrl}/get_result`); url.searchParams.set("id", taskId); url.searchParams.set("compress", "0"); @@ -162,8 +168,7 @@ await Bun.write("model.ply", buf); // Bun ### Complete 2D to 3D pipeline example (selectable output) ```ts const API_KEY = "{YOUR-API-KEY}"; -const GATEWAY = "gateway-eu.404.xyz"; -const BASE_URL = `https://${GATEWAY}:4443`; +const BASE_URL = "https://api.dns.404.xyz"; // GeoDNS; replace with a regional URL if needed // Choose output format: "spz" (default, compressed) or "ply" (compress=0) const OUTPUT_FORMAT = "ply"; // or "spz" diff --git a/src/http3/handlers/admin.rs b/src/http3/handlers/admin.rs index 1aeebda..0d82321 100644 --- a/src/http3/handlers/admin.rs +++ b/src/http3/handlers/admin.rs @@ -23,7 +23,7 @@ pub async fn generic_key_update_handler( )) } -// curl --http3 -X GET "https://gateway-eu.404.xyz:4443/get_key" -H "x-admin-key: b6c8597a-00e9-493a-b6cd-5dfc7244d46b" +// curl --http3 -X GET "https://api.dns.404.xyz/get_key" -H "x-admin-key: b6c8597a-00e9-493a-b6cd-5dfc7244d46b" #[handler] pub async fn generic_key_read_handler( depot: &mut Depot, diff --git a/src/http3/handlers/result/add_result.rs b/src/http3/handlers/result/add_result.rs index 3c5765d..05d17d0 100644 --- a/src/http3/handlers/result/add_result.rs +++ b/src/http3/handlers/result/add_result.rs @@ -14,7 +14,7 @@ use super::add_result_log::{ use super::add_result_parse::{ParsedAddResultRequest, parse_add_result_request}; // Add successful result -// curl --http3 -X POST https://gateway-eu.404.xyz:4443/add_result \ +// curl --http3 -X POST https://api.dns.404.xyz/add_result \ // -F id=123e4567-e89b-12d3-a456-426614174001 \ // -F signature=signature \ // -F timestamp=404_GATEWAY_1713096000 \ @@ -25,7 +25,7 @@ use super::add_result_parse::{ParsedAddResultRequest, parse_add_result_request}; // -F asset=@/path/to/result.spz // Add failed result -// curl --http3 -X POST https://gateway-eu.404.xyz:4443/add_result \ +// curl --http3 -X POST https://api.dns.404.xyz/add_result \ // -F id=987e6543-e21b-45d6-c789-123456789abc \ // -F signature=signature \ // -F timestamp=404_GATEWAY_1713096000 \ diff --git a/src/http3/handlers/result/read.rs b/src/http3/handlers/result/read.rs index 7957f20..3237d39 100644 --- a/src/http3/handlers/result/read.rs +++ b/src/http3/handlers/result/read.rs @@ -173,11 +173,11 @@ async fn authorize_task_read_access( } } -// curl --http3 "https://gateway-eu.404.xyz:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ +// curl --http3 "https://api.dns.404.xyz/get_result?id=123e4567-e89b-12d3-a456-426614174000" \ // -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" \ // -o result.ply -// curl --http3 "https://gateway-eu.404.xyz:4443/get_result?id=123e4567-e89b-12d3-a456-426614174000&all=true" \ +// curl --http3 "https://api.dns.404.xyz/get_result?id=123e4567-e89b-12d3-a456-426614174000&all=true" \ // -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" \ // -o results.zip #[handler] @@ -382,7 +382,7 @@ pub async fn get_result_handler( Ok(()) } -// curl --http3 "https://gateway-eu.404.xyz:4443/get_status?id=123e4567-e89b-12d3-a456-426614174000" +// curl --http3 "https://api.dns.404.xyz/get_status?id=123e4567-e89b-12d3-a456-426614174000" #[handler] pub async fn get_status_handler( depot: &mut Depot, diff --git a/src/http3/handlers/task/add_task.rs b/src/http3/handlers/task/add_task.rs index beb7664..fc62026 100644 --- a/src/http3/handlers/task/add_task.rs +++ b/src/http3/handlers/task/add_task.rs @@ -27,9 +27,11 @@ use super::add_task_parse::{parse_add_task_request, validate_add_task_input}; use super::add_task_rate_limit::{PendingRateLimitRollbackGuard, publish_accepted_reservation}; use super::current_time_ms; -// curl --http3 -X POST "https://gateway-eu.404.xyz:4443/add_task" -H "content-type: application/json" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" -d '{"prompt": "mechanic robot", "seed": 12345}' -// curl --http3 -X POST "https://gateway-eu.404.xyz:4443/add_task" -F "prompt=a robot" -F "seed=12345" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" -// curl --http3 -X POST "https://gateway-eu.404.xyz:4443/add_task" -F "image=@image.jpg" -F "seed=12345" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" +// GeoDNS endpoint: https://api.dns.404.xyz. Regional endpoints: +// https://api-eu.404.xyz, https://api-us-east.404.xyz, https://api-us-west.404.xyz. +// curl --http3 -X POST "https://api.dns.404.xyz/add_task" -H "content-type: application/json" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" -d '{"prompt": "mechanic robot", "seed": 12345}' +// curl --http3 -X POST "https://api.dns.404.xyz/add_task" -F "prompt=a robot" -F "seed=12345" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" +// curl --http3 -X POST "https://api.dns.404.xyz/add_task" -F "image=@image.jpg" -F "seed=12345" -H "x-api-key: 123e4567-e89b-12d3-a456-426614174001" #[handler] pub async fn add_task_handler( depot: &mut Depot, diff --git a/src/http3/handlers/task/get_load.rs b/src/http3/handlers/task/get_load.rs index d391b69..74ee049 100644 --- a/src/http3/handlers/task/get_load.rs +++ b/src/http3/handlers/task/get_load.rs @@ -6,7 +6,7 @@ use crate::http3::depot_ext::DepotExt; use crate::http3::error::ServerError; use crate::http3::state::HttpState; -// curl --http3 -X GET -k https://gateway-eu.404.xyz:4443/get_load +// curl --http3 -X GET https://api.dns.404.xyz/get_load #[handler] pub async fn get_load_handler( depot: &mut Depot, diff --git a/src/http3/handlers/task/get_tasks.rs b/src/http3/handlers/task/get_tasks.rs index 29532ef..7de79ed 100644 --- a/src/http3/handlers/task/get_tasks.rs +++ b/src/http3/handlers/task/get_tasks.rs @@ -19,7 +19,7 @@ use crate::raft::gateway_state::WorkerEventRef; use super::{current_time_ms, task_kind_label}; -// curl --http3 -X POST https://gateway-eu.404.xyz:4443/get_tasks \ +// curl --http3 -X POST https://api.dns.404.xyz/get_tasks \ // -H "content-type: application/json" \ // -d '{"validator_hotkey": "abc123", "worker_id": "worker-123", "signature": "signatureinbase64", "timestamp": "404_GATEWAY_1743657200", "requested_task_count": 10}' #[handler]