> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Deleting a file {% mark class="http-delete" %}{% icon name="close" /%}`DELETE`{% /mark %} `https://generativelanguage.googleapis.com/v1beta/files/{file}` Deletes the [`File`](/api-reference/files#Resource:File). {% two-column-layout %} {% left-column %} ## Parameters {% class="hide-from-toc" id="parameters" %} {% section class="api-ref-property-list" %} **file**: {% mark %}required{% /mark %} `string` The file ID. Forms the resource name `files/{file}`. {% /section %} {% /left-column %} {% right-column class="sticky" %} **Example request** {% class="example-heading" %} {% tabs %} {% tab label="REST" %} ```sh curl --request "DELETE" https://generativelanguage.googleapis.com/v1beta/files/$name?key=$GEMINI_API_KEY ``` {% /tab %} {% tab label="Python" %} ```python from google import genai client = genai.Client() myfile = client.files.upload(file=media / "poem.txt") client.files.delete(name=myfile.name) try: result = client.models.generate_content( model="gemini-3.8-flash", contents=[myfile, "Describe this file."] ) print(result) except genai.errors.ClientError: pass ``` {% /tab %} {% tab label="Go" %} ```go ctx := context.Background() client, err := genai.NewClient(ctx, &genai.ClientConfig{ APIKey: os.Getenv("GEMINI_API_KEY"), Backend: genai.BackendGeminiAPI, }) if err != nil { log.Fatal(err) } myfile, err := client.Files.UploadFromPath( ctx, filepath.Join(getMedia(), "poem.txt"), &genai.UploadFileConfig{ MIMEType: "text/plain", }, ) if err != nil { log.Fatal(err) } // Delete the file. _, err = client.Files.Delete(ctx, myfile.Name, nil) if err != nil { log.Fatal(err) } // Attempt to use the deleted file. parts := []*genai.Part{ genai.NewPartFromURI(myfile.URI, myfile.MIMEType), genai.NewPartFromText("Describe this file."), } contents := []*genai.Content{ genai.NewContentFromParts(parts, genai.RoleUser), } _, err = client.Models.GenerateContent(ctx, "gemini-3.8-flash", contents, nil) // Expect an error when using a deleted file. if err != nil { return nil } return fmt.Errorf("expected an error when using deleted file") ``` {% /tab %} {% /tabs %} {% /right-column %} {% /two-column-layout %} ## Response {% class="hide-from-toc" id="response" %} {% section class="api-ref-property-list" /%}