Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fal-ai/fal-java
A JVM-compatible, Java & Kotlin, client for the fal.ai model APIs
https://github.com/fal-ai/fal-java
ai fal generative-ai java kotlin
Last synced: about 11 hours ago
JSON representation
A JVM-compatible, Java & Kotlin, client for the fal.ai model APIs
- Host: GitHub
- URL: https://github.com/fal-ai/fal-java
- Owner: fal-ai
- License: mit
- Created: 2023-12-01T16:51:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-10T03:34:08.000Z (3 months ago)
- Last Synced: 2024-12-15T22:43:41.116Z (8 days ago)
- Topics: ai, fal, generative-ai, java, kotlin
- Language: Java
- Homepage: https://fal.ai
- Size: 499 KB
- Stars: 12
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## The fal.ai JVM Client for Java and Kotlin
![License](https://img.shields.io/badge/license-MIT-blue)
## About the Project
The `FalClient` is a robust and user-friendly Java implementation of the [fal.ai](https://fal.ai) client.
## Getting Started
The `FalClient` library serves as a client for fal serverless Python functions. Before using this library, ensure you've got your fal key from [our dashboard](https://fal.ai/dashboard/keys).
The client is available on Maven Central. There are three different modules:
- `fal-client`: The main client library, implemented in Java, with synchronous interfaces.
- `fal-client-async`: The asynchronous version of the client library, implemented in Java.
- `fal-client-kotlin`: The Kotlin version of the client library, with coroutines support, implemented on top of the `fal-client-async` module.The
### Client Library
#### Synchronous
##### Install
```groovy
implementation "ai.fal.client:fal-client:0.7.1"
```##### Call the API
```java
import ai.fal.client.*;var fal = FalClient.withEnvCredentials();
var input = Map.of(
"prompt", "A cute shih-tzu puppy"
);
var result = fal.subscribe("fal-ai/fast-sdxl",
SubscribeOptions.builder()
.input(input)
.resultType(JsonObject.class)
.onQueueUpdate(update -> {
System.out.println(update.getStatus());
})
.build()
);
System.out.println(result.getRequestId());
System.out.println(result.getData());
```#### Asynchronous
##### Install
```groovy
implementation "ai.fal.client:fal-client-async:0.7.1"
```##### Call the API
```java
import ai.fal.client.*;var fal = AsyncFalClient.withEnvCredentials();
var input = Map.of(
"prompt", "A cute shih-tzu puppy"
);
var future = fal.subscribe("fal-ai/fast-sdxl",
SubscribeOptions.builder()
.input(input)
.resultType(JsonObject.class)
.onQueueUpdate(update -> {
System.out.println(update.getStatus());
})
.build()
);
future.thenAccept(result -> {
System.out.println(result.getRequestId());
System.out.println(result.getData());
});
```#### Kotlin
##### Install
```groovy
implementation "ai.fal.client:fal-client-kotlin:0.7.1"
```##### Call the API
```kotlin
import ai.fal.client.kt.*val fal = createFalClient()
val result = fal.subscribe("fal-ai/fast-sdxl", input = mapOf(
"prompt" to "A cute shih-tzu puppy"
)) { update ->
print(update.status)
}
print(result.requestId)
print(result.data)
```## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make to the Kotlin version of the client are **greatly appreciated**.
## License
Distributed under the MIT License. See [LICENSE](https://github.com/fal-ai/serverless-client-swift/blob/main/LICENSE) for more information.