stability-sdk
stability-sdk copied to clipboard
JS SDK?
Is there a plan to provide a JS SDK, or expose the API over HTTP so we can use this API from frontend apps without backend?
This can greatly reduce time to deploy, will allow many frontend developers to built UIs and applications, will allow for "self serve" applications, that users could paste their own API keys to, chrome extensions and more.
Same question here
We've uploaded the protobuf definitions for the API here: https://github.com/Stability-AI/stability-sdk/blob/main/src/proto/generation.proto
This should enable users to build a client in any language that supports gRPC. We'll roll out code to demonstrate connecting in other languages soon. I'm hoping the protobuf spec will be enough to get the ball rolling for the time being though.
We've uploaded the protobuf definitions for the API here: https://github.com/Stability-AI/stability-sdk/blob/main/src/proto/generation.proto
This should enable users to build a client in any language that supports gRPC. We'll roll out code to demonstrate connecting in other languages soon. I'm hoping the protobuf spec will be enough to get the ball rolling for the time being though.
Thank you! I'm currently working on a client-side Swift implementation for iOS.
Update: Working like a charm!
I was unable to use the proto file. Hope you make a javascript sdk.
@svumme I've added precompiled stubs for javascript and typescript here: https://github.com/Stability-AI/stability-sdk/tree/main/src/js
I'll close this issue once we've got demo usage documented
I've actually created a typescript client/CLI that uses the stability-sdk typescript that you've precompiled, @dmarx. (CC @altryne @Pau-Lozano @kaishin @svumm)
https://github.com/jakiestfu/stability-ts
In case folks are interested, I've got another example of using the gRPC service from TypeScript at https://github.com/jeffposnick/magic-realism-dream-bot/tree/main/proto
That example uses the https://www.npmjs.com/package/@grpc/grpc-js client, which I believe is the most "modern" of the various gRPC libraries for JavaScript/TypeScript.
I've also since updated the JS SDK to use the new stability-sdk
repo https://github.com/jakiestfu/stability-ts
@jakiestfu I'm getting this error when trying to use it
Error: Must provide image parameters.
Anyone know what's going on here?
"UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-09-22T16:12:19.839528-06:00", grpc_status:3, grpc_message:"Must provide image parameters."}"
Anyone know what's going on here?
"UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-09-22T16:12:19.839528-06:00", grpc_status:3, grpc_message:"Must provide image parameters."}"
@CedYF @dholbrook86 @jakiestfu You should no longer pass ClassifierParameters in the request (for Jake's TS client, remove line 145 and 146 of index.ts)
Apologies for the breaking change. The python client should work if you update the pip package.
So is it possible to connect to beta.dreamstudio.ai or any other URL from Stability AI to use the Stable Diffusion? Should I send protocol buffers as binary data over the HTTP POST request? What URL should I communicate with?
Anyone know what's going on here?
"UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-09-22T16:12:19.839528-06:00", grpc_status:3, grpc_message:"Must provide image parameters."}"
@CedYF @dholbrook86 @jakiestfu You should no longer pass ClassifierParameters in the request (for Jake's TS client, remove line 145 and 146 of index.ts)
Apologies for the breaking change. The python client should work if you update the pip package.
but when at the linux, it still appear the same error message, even if I use the command pip install --upgrade stability-sdk
, at the windows, it can work now, any other steps should I do at the linux?
@photopea
So is it possible to connect to beta.dreamstudio.ai or any other URL from Stability AI to use the Stable Diffusion? Should I send protocol buffers as binary data over the HTTP POST request? What URL should I communicate with?
You should use https://grpc.stability.ai:443 (which is the default) for the URL. There are no other production URLs at present. The API keys can be managed at https://beta.dreamstudio.ai/membership?tab=apiKeys
Currently, the best way to send the request in js/ts is to make a submodule of https://github.com/Stability-AI/api-interfaces. Then import Generation from "api-interfaces/gooseai/generation/generation_pb";
and import { grpc } from "@improbable-eng/grpc-web";
You can then construct a request const request = new Generation.Request();
and send it over grpc. We hope to provide an easier official way of doing this soon, but in the mean time you can have a look at https://github.com/vpzomtrrfrt/stability-client/blob/main/src/index.ts for reference of what needs to go into the request (or use @vpzomtrrfrt 's package https://github.com/vpzomtrrfrt/stability-client )
@TandK8600
Anyone know what's going on here?
"UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-09-22T16:12:19.839528-06:00", grpc_status:3, grpc_message:"Must provide image parameters."}"
@CedYF @dholbrook86 @jakiestfu You should no longer pass ClassifierParameters in the request (for Jake's TS client, remove line 145 and 146 of index.ts) Apologies for the breaking change. The python client should work if you update the pip package.
but when at the linux, it still appear the same error message, even if I use the command
pip install --upgrade stability-sdk
, at the windows, it can work now, any other steps should I do at the linux?
On your linux box, are you using the pip package, or a cloned version of this repository? (if the command you run to invoke is python3 -m stability_sdk.client
then you are probably using the pip version, if the command you run to invoke is python3 src/stability_sdk/client.py
then you are using the cloned repository.
If the pip package, when you run pip show stability-sdk
do you see version 0.2.5?
If the cloned repo, make sure that you have the latest (git pull
and git submodule update --init --recursive
)
@chigozienri Thanks, but I am getting "404 page not found" as a HTTP response. I tried to send empty data both through GET and POST method. Do I need to set any specific HTTP headers? See my code here: https://jsfiddle.net/qehusm9f/
Is there any clear description of the API, which does not require using any of your libraries?
(I'm not affiliated with this project.)
@photopea, I think your best bet would be to read through https://grpc.io/about/, as from what I can tell, the Stable Diffusion API is exposed as a "standard" gRPC endpoint. It's not trivial to interact with an gRPC endpoint without using a helper library, as you'd need to serialize and deserialize protobuffs yourself.
https://grpc.io/docs/platforms/web/basics/ is the library that most folks use for accessing gRPC services from the browser, and it will handle both the transport and serialization/deserialization for you.
@photopea Thanks for sending your code snippet, that makes it clearer. As @jeffposnick says, you can't simply send an HTTP GET or POST request, it needs to be a gRPC call. We do not have a REST API available at present (there is a small discussion on this here) - nor, unfortunately, do we have a description for using the API other than to look at the protos, or to emulate how they are used in the python client in this repo/ other people's implementations such as https://github.com/vpzomtrrfrt/stability-client
I am familiar with protocol buffers and I am planning to communicate through them. But I am curious, why your server does not return any error message, but returns "404" instead.
If I use the same code as in https://jsfiddle.net/qehusm9f/, but send a valid protocol buffer data, will it start to work?
Hi, with regards to this issue ""UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-09-22T16:12:19.839528-06:00", grpc_status:3, grpc_message:"Must provide image parameters."}"" The error still persist on linux despite updating/upgrading to the newest version 0.2.6 (I,m working with AWS Lambda Python Version 3.7). Does anyone have any idea how to recitfy this ?
Same issue on Google Cloud Functions:
line 48, in stabilityai for resp in answers: File "/layers/google.python.pip/pip/lib/python3.7/site-packages/stability_sdk/client.py", line 300, in generate for answer in self.stub.Generate(rq, **self.grpc_args): File "/layers/google.python.pip/pip/lib/python3.7/site-packages/grpc/_channel.py", line 426, in __next__ return self._next() File "/layers/google.python.pip/pip/lib/python3.7/site-packages/grpc/_channel.py", line 826, in _next raise self grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Must provide image parameters." debug_error_string = "UNKNOWN:Error received from peer ipv4:104.18.20.212:443 {created_time:"2022-10-19T15:46:11.888314867+00:00", grpc_status:3, grpc_message:"Must provide image parameters."}"
@mohsendelsouz Hi, it seems that this issue was solved at #55 and subsequently merged with #64, where all we needed to do was remove the classifiers. Credit to @sayanarijit.
Could you make a simple HTTP API, which does not require implementing Protocol Buffers, or using huge JS libraries?
Look at the API of DALL-E: https://beta.openai.com/docs/api-reference/images/create
I would definitely echo @photopea's comment. A REST API would open up a lot of possibilities.
To give you some additional tangibles, here are other environments/projects where it's very difficult to implement gRPC:
- Krita plugins (@imperator-maximus created his own python grpc implementation, because Krita doesn't allow 3rd party libs)
- Blender add-ons (I jumped through a lot of hoops to create my own wrapper API for Stability SDK, because Blender doesn't have reliable/easy support for outside libs)
- Any website, like others have discussed above
PS. I LOVE Stable Diffusion, and just want more developers to be able to integrate it!
We've uploaded the protobuf definitions for the API here: https://github.com/Stability-AI/stability-sdk/blob/main/src/proto/generation.proto This should enable users to build a client in any language that supports gRPC. We'll roll out code to demonstrate connecting in other languages soon. I'm hoping the protobuf spec will be enough to get the ball rolling for the time being though.
Thank you! I'm currently working on a client-side Swift implementation for iOS.
Update: Working like a charm!
May I ask how you achieved it? I want to inherit it into Macapp, which is also developed in Swift.
I would definitely echo @photopea's comment. A REST API would open up a lot of possibilities.
To give you some additional tangibles, here are other environments/projects where it's very difficult to implement gRPC:
- Krita plugins (@imperator-maximus created his own python grpc implementation, because Krita doesn't allow 3rd party libs)
- Blender add-ons (I jumped through a lot of hoops to create my own wrapper API for Stability SDK, because Blender doesn't have reliable/easy support for outside libs)
- Any website, like others have discussed above
PS. I LOVE Stable Diffusion, and just want more developers to be able to integrate it!
see my detailed comment on this: https://github.com/Stability-AI/stability-sdk/discussions/51#discussioncomment-4171959 In short: grpc was a nice idea but it failed. so better use REST only in future.
@all see this comment: https://github.com/Stability-AI/stability-sdk/discussions/51#discussioncomment-4218518
It sounds like JS will be much more easily supported soon!
@svumme I've added precompiled stubs for javascript and typescript here: https://github.com/Stability-AI/stability-sdk/tree/main/src/js
I'll close this issue once we've got demo usage documented
broken link
REST API developer preview was just released! https://twitter.com/jcsabath/status/1597629332184145920
Could you support CORS in your REST API? One website can not load a single byte of data (HTTP request) from another domain, if you dont allow it explicitly in CORS headers.