Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions sdk/apps/deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ When your app works in a [dev session](/sdk/apps/dev-sessions), deploy it to cre
rp flash deploy
```

The command finds every app in the current directory, builds an artifact for each one, uploads it, and creates or updates the endpoints in the target environment. When it finishes, it prints a link to each endpoint.
The command finds every app in the current directory, builds an artifact for each one, uploads it, and creates or updates the endpoints in the target environment. When it finishes, it lists every resource in the app. Queue and API resources show a link to their endpoint. Tasks show as registered, because each task call provisions its own Pod.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

To deploy a different directory, pass it as an argument: `rp flash deploy path/to/project`.

Expand Down Expand Up @@ -64,7 +64,7 @@ These paths are left out of every artifact, and negation patterns can't re-inclu

## Call deployed resources

From another codebase, use `runpod.Queue` and `runpod.Api` to call resources in a deployed app by name:
From another codebase, use `runpod.Queue`, `runpod.Api`, and `runpod.Task` to call resources in a deployed app by name:

```python
import runpod
Expand All @@ -74,9 +74,20 @@ result = transcribe.remote(audio_url="https://example.com/audio.mp3")

inference = runpod.Api(app="media", name="inference")
response = inference.post("/generate", {"prompt": "hi"})

train = runpod.Task(app="media", name="train")
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved
job = train.spawn(steps=500) # Use train.remote(...) to wait for the result
```

Both target the `default` environment unless you pass `env=`.
Each stub targets the `default` environment unless you pass `env=`. Arguments and results must be JSON-compatible. See [Arguments and return values](/sdk/apps/dev-sessions#arguments-and-return-values).

From your machine, these calls use your account credentials from `rp login` or `RUNPOD_API_KEY`, so they can reach any app that your API key has permission to call.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

### Calls from deployed workers

Deployed workers don't receive your API key. Runpod issues each endpoint and task Pod its own runtime credentials, and the SDK uses them for calls the worker makes to other resources. With these credentials, a deployed worker can call only resources in its own app and environment. This applies to `.remote()` calls on your resources and to `runpod.Queue`, `runpod.Api`, and `runpod.Task` stubs. A call to another app or environment fails.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

Because Runpod sets these credentials, your resources can't use some environment variable names. See [env](/sdk/configuration/parameters#env).

You can also call a deployed queue endpoint by ID with the [endpoint client](/sdk/overview#endpoint-client), or send HTTP requests to it directly. See [Send API requests](/serverless/endpoints/send-requests).

Expand Down
13 changes: 12 additions & 1 deletion sdk/apps/dev-sessions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The command exits with an error if the entrypoint fails, so you can use it as a

## Python version

In a dev session, and for every task call, the SDK sends your function to the worker as a serialized payload produced by your local Python. The worker must run the same Python version, so your local interpreter must be one of the supported versions: 3.10, 3.11, 3.12, 3.13, or 3.14. An unsupported version fails with an error before anything is provisioned.
In a dev session, and for task calls from your machine, the SDK sends your function's source code to the worker. The worker runs the same Python version as your machine so that syntax and language behavior match. Your local interpreter must be one of the supported versions: 3.10, 3.11, 3.12, 3.13, or 3.14. An unsupported version fails with an error before anything is provisioned.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

## Write code that works in a session

Expand All @@ -60,6 +60,17 @@ Inside an entrypoint, call your resources in whichever way suits the work:

`remote()` and `job.wait()` don't impose an execution timeout by default.

### Arguments and return values

Remote calls send arguments, return values, and stream chunks as JSON. Use JSON-compatible values: strings, numbers, booleans, `None`, lists, and dictionaries. The SDK converts values the way Python's `json` module does, including when a function calls another function on the same worker:
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

- Tuples arrive as lists.
- Dictionary keys that are numbers, booleans, or `None` arrive as strings.

Bytes, custom objects such as NumPy arrays or tensors, circular references, and `NaN` or infinite floats make the call fail with an error. Convert them before you pass or return them, for example with `tensor.tolist()`. For large binary data, such as model weights or images, write the data to a [volume](/sdk/configuration/storage) and return its path.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

`fn.local(...)` is a direct Python call, so it accepts and returns any Python value.

### Spawned tasks

Calling `.spawn()` on a task returns a job that owns its Pod:
Expand Down
18 changes: 18 additions & 0 deletions sdk/configuration/parameters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@ def infer(): ...

Create secrets with `rp secret add`. Secret values never pass through the SDK.

Runpod sets runtime identity and credential variables on deployed workers, so `rp flash deploy` fails if `env` uses a reserved name. Queue and API resources can't use these names:
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

- Credentials: `RUNPOD_API_KEY` and `RUNPOD_AI_API_KEY`.
- Worker identity: `RUNPOD_ENDPOINT_ID`, `RUNPOD_POD_ID`, `RUNPOD_BUILD_ID`, and `RUNPOD_RUNTIME_KIND`.
- App identity: `FLASH_APP_NAME`, `FLASH_ENVIRONMENT`, `FLASH_RESOURCE_NAME`, and `FLASH_BUILD_ARTIFACT_PATH`.
- Task and dev session internals: `RUNPOD_TASK_TOKEN`, `RUNPOD_TASK_PORT`, `RUNPOD_DEV_APP`, `RUNPOD_DEV_RESOURCE`, and `RUNPOD_DEV_SESSION`.

Tasks can't use any name that starts with `RUNPOD_` or `FLASH_`, in any letter case. They also can't use `PYTHONPATH`, `PYTHONHOME`, or `LD_PRELOAD`.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

If your code needs its own Runpod API key, store it as a secret under a name that isn't reserved:

```python
@app.queue(cpu="cpu3c-1-2", env={"MY_RUNPOD_API_KEY": runpod.Secret("runpod-api-key")})
def manage(): ...
```

To call other resources in the same app, you don't need a key. See [Calls from deployed workers](/sdk/apps/deploy#calls-from-deployed-workers).

<Warning>
Values in a local `.env` file aren't sent to workers, and `.env` files are always left out of deployments. Pass every variable your workers need through `env`.
</Warning>
Expand Down
2 changes: 2 additions & 0 deletions sdk/configuration/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ runpod.GlobalVolume(name_or_id, create=True)
| `@app.queue` and `@app.api` | One volume | `/runpod-volume` |
| `@app.task` | One network volume and one global volume | Any paths that don't overlap |

When you deploy an app, a task's mount paths also can't overlap paths that the runtime reserves: `/root/.runpod`, `/runpod-volume`, `/proc`, `/sys`, and `/dev`. A mount path overlaps when it equals a reserved path, contains one, or sits inside one.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

Global volumes require GPU compute for both tasks and endpoints.

## Read the mount path in your code
Expand Down
4 changes: 4 additions & 0 deletions serverless/workers/handler-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ runpod.serverless.start({"handler": handler})

Exercise caution when using `try/except` blocks to avoid unintentionally suppressing errors. Either return the error for a graceful failure or raise it to flag the job as `FAILED`.

### Results that aren't valid JSON

Job results travel as JSON. Your handler's return value, and each chunk a streaming handler yields, must be JSON-serializable with finite numbers. If a result contains a value such as bytes, a NumPy array, or `NaN`, the job fails. The SDK marks it as `FAILED` and returns the serialization error in the job results. Convert these values before you return them, for example with `array.tolist()`. Upload binary data to cloud storage and return a link instead.
Comment thread
promptless[bot] marked this conversation as resolved.
Resolved

## Advanced handler controls

Use these features to fine-tune your Serverless applications for specific use cases.
Expand Down
Loading