
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
This is a Python client library for interacting with ML models deployed on fal.ai.
To install the client, run:
pip install fal-client
To use the client, you need to have an API key. You can get one by signing up at fal.ai. Once you have it, set it as an environment variable:
export FAL_KEY=your-api-key
Now you can use the client to interact with your models. Here's an example of how to use it:
import fal_client
response = fal_client.run("fal-ai/fast-sdxl", arguments={"prompt": "a cute cat, realistic, orange"})
print(response["images"][0]["url"])
The client also supports asynchronous requests out of the box. Here's an example:
import asyncio
import fal_client
async def main():
response = await fal_client.run_async("fal-ai/fast-sdxl", arguments={"prompt": "a cute cat, realistic, orange"})
print(response["images"][0]["url"])
asyncio.run(main())
If the model requires files as input, you can upload them directly to fal.media (our CDN) and pass the URLs to the client. Here's an example:
import fal_client
audio_url = fal_client.upload_file("path/to/audio.wav")
response = fal_client.run("fal-ai/whisper", arguments={"audio_url": audio_url})
print(response["text"])
If you don't want to upload your file to our CDN service (for latency reasons, for example), you can encode it as a data URL and pass it directly to the client. Here's an example:
import fal_client
audio_data_url = fal_client.encode_file("path/to/audio.wav")
response = fal_client.run("fal-ai/whisper", arguments={"audio_url": audio_data_url})
print(response["text"])
When you want to send a request and keep receiving updates on its status, you can use the submit
method. Here's an example:
import asyncio
import fal_client
async def main():
response = await fal_client.submit_async("fal-ai/fast-sdxl", arguments={"prompt": "a cute cat, realistic, orange"})
logs_index = 0
async for event in response.iter_events(with_logs=True):
if isinstance(event, fal_client.Queued):
print("Queued. Position:", event.position)
elif isinstance(event, (fal_client.InProgress, fal_client.Completed)):
new_logs = event.logs[logs_index:]
for log in new_logs:
print(log["message"])
logs_index = len(event.logs)
result = await response.get()
print(result["images"][0]["url"])
asyncio.run(main())
FAQs
Python client for fal.ai
We found that fal-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.