Forum Academy Marketplace Showcase Pricing Features

Uploading file via API

I’m trying to upload a file via API. Here is the documentation: muse.ai | apis

Request should look like:
curl -X POST
-H “Key: YOUR_KEY”
-F “file=@The_Solar_System.mp4”
https://muse.ai/api/files/upload

And this is what I have (key removed for privacy):

Yet I am receiving the error:
There was an issue setting up your call.
Raw response for the API
Status code 400
{“error”:“missing_file”}

I have a feeling it has to do with the way the file is called, but looking for someone else’s input.
Its my first time with cURL and it was going great until this file upload!

you don’t provide the file at all and you enter a curl parameter in body that won’t work.
Delete content type header, change Body type to Form-data and add a parameter “file” and select file for the type.

Upload a file to the file field and initialize. It should work

WOW worked like a charm. Thank you so much!!

1 Like

Hello. I managed to make it available as an editor. it would be very useful

Hey @Jici , I am trying to do what you suggested for OpenAI fine tunning

But I am getting this error

WEOFWJOIEFW

Adding the header:

Content-Type: application/json

generates the same error.

Any help would be appreciated! Thanks!

@pachocastillosr Do multipart/form-data for the Content-type

1 Like

Thanks for replying @tylerboodman ! This is what I got:

WEOFWJOIEFW

Oops I didn’t read the whole response, yes sorry use appliation/json, but according to OpenAI’s docs you have to upload the file first like the solution in this post.

Then when it returns the file ID that’s what you send to the call you are trying to make but in a standard JSON body, not Form-data

2 Likes

Upload file using a post to https://api.openai.com/v1/files and it will give you a file ID that you will use in further call

2 Likes

You are both right, thanks a lot! @tylerboodman @Jici

2 Likes

How i can upload the file dynamically from the user

2 Likes

Same problem here, and no answers found.

1 Like

Try to get the curl from the api provider

Its works for me

I’m trying to use Stability API image-to-image generation, and the cURL they give it’s this one.
Though I’m still unsure how this solves my issue of dynamically sending users image uploading images. All help is much welcome.

OUTPUT_FILE=./out/v1_img2img.png
BASE_URL=${API_HOST:-https://api.stability.ai}
URL="$BASE_URL/v1/generation/stable-diffusion-v1-5/image-to-image"

curl -f -sS -X POST "$URL" \
  -H 'Content-Type: multipart/form-data' \
  -H 'Accept: image/png' \
  -H "Authorization: Bearer $STABILITY_API_KEY" \
  -F 'init_image=@"../init_image.png"' \
  -F 'init_image_mode=IMAGE_STRENGTH' \
  -F 'image_strength=0.35' \
  -F 'text_prompts[0][text]=A galactic dog in space' \
  -F 'cfg_scale=7' \
  -F 'clip_guidance_preset=FAST_BLUE' \
  -F 'samples=1' \
  -F 'steps=30' \
  -o "$OUTPUT_FILE"

Did you check import curl in the Api connector