acoustic-carpenter-78188
03/27/2026, 2:27 AMflyte create secret --project flytesnacks --domain development OPENAI_API_KEY --value secret123
2. Run a workflow with task printing values from secret
import asyncio
import logging
import os
from typing import List
import flyte
env = flyte.TaskEnvironment(
name="hello_world",
resources=flyte.Resources(cpu=1, memory="1Gi"),
secrets=flyte.Secret("OPENAI_API_KEY", as_env_var="OPENAI_API_KEY"),
)
@env.task
async def say_hello(data: str) -> str:
print(f"Hello, world! - {flyte.ctx().action}")
secret_val = os.environ.get("OPENAI_API_KEY", "NOT_FOUND")
print(f"[webhook test] OPENAI_API_KEY={secret_val}")
return f"Hello {data}, secret={secret_val}"
@env.task
async def say_hello_nested(data: str = "default string") -> str:
return await say_hello(data=data)
if __name__ == "__main__":
flyte.init_from_config()
run = flyte.with_runcontext(
log_level=logging.DEBUG,
env_vars={"KEY": "V"},
labels={"Label1": "V1"},
annotations={"Ann": "ann"},
overwrite_cache=True,
interruptible=False,
).run(say_hello_nested, data="hello world")
print(run.name)
print(run.url)
run.wait()
1. Log the task pod, we see the secret printed out Screenshot 2026-03-27 at 10 26 50 AM
Labels
Please add one or more of the following labels to categorize your PR:
• added: For new features.
• changed: For changes in existing functionality.
• deprecated: For soon-to-be-removed features.
• removed: For features being removed.
• fixed: For any bug fixed.
• security: In case of vulnerabilities
This is important to improve the readability of release notes.
Setup process
Screenshots
Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits are signed-off.
Related PRs
Docs link
• main
• #6583
• [V2]Fix secret injection error in sandbox 👈
flyteorg/flyteacoustic-carpenter-78188
03/27/2026, 4:05 AM