Skip to content

feat: add api endpoints for chat attachments#1173

Merged
disintegrator merged 4 commits intomainfrom
asset-attachments
Jan 9, 2026
Merged

feat: add api endpoints for chat attachments#1173
disintegrator merged 4 commits intomainfrom
asset-attachments

Conversation

@disintegrator
Copy link
Contributor

Authored by Claude Opus 4.5

This change updates the assets service to include new API endpoints for uploading and serving chat attachments.

The /rpc/assets.serveChatAttachment endpoint can be accessed with an API key or session cookie. Gram-Project is not used on that endpoint to make it easy for session-based clients to embed attachments in chat such as with <img> tags for images e.g. <img src="/rpc/assets.serveChatAttachment?id=...&project_id=..." />.

@disintegrator disintegrator requested a review from a team as a code owner January 9, 2026 15:16
@changeset-bot
Copy link

changeset-bot bot commented Jan 9, 2026

🦋 Changeset detected

Latest commit: 7f130dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
server Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
gram Ready Ready Preview, Comment Jan 9, 2026 5:48pm
gram-docs-redirect Ready Ready Preview, Comment Jan 9, 2026 5:48pm

Copy link
Contributor

@tgmendes tgmendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - non-blocking suggestion but otherwise 🚀

MaxFileSizeFunctions = 15 * mib
MaxFileSizeOpenAPI = 10 * mib
MaxFileSizeImage = 4 * mib
mib = 1024 * 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Comment on lines 930 to 941
explicitTypes := []string{
"application/json",
"application/yaml", "application/x-yaml",
}
if slices.Contains(explicitTypes, mediaType) {
switch mediaType {
case "application/json":
return mediaType, ".json", nil
case "application/yaml", "application/x-yaml":
return mediaType, ".yaml", nil
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option:

Suggested change
explicitTypes := []string{
"application/json",
"application/yaml", "application/x-yaml",
}
if slices.Contains(explicitTypes, mediaType) {
switch mediaType {
case "application/json":
return mediaType, ".json", nil
case "application/yaml", "application/x-yaml":
return mediaType, ".yaml", nil
}
}
explicitTypeExtensions := map[string]string{
"application/json": ".json",
"application/yaml": ".yaml",
"application/x-yaml": ".yaml",
}
extension, ok := explicitTypeExtensions[mediaType]
if ok {
return mediaType, extension, nil
}

Would make it easier to add more types if needed as you don't need to explicitly add a new switch statement. Also a bit more concise and readable IMO.

This change updates the assets service to include new API endpoints
for uploading and serving chat attachments.

The `/rpc/assets.serveChatAttachment` endpoint can be accessed with an
API key or session cookie. `Gram-Project` is not used on that endpoint
to make it easy for session-based clients to embed attachments in chat
such as with `<img>` tags for images e.g.
`<img src="/rpc/assets.serveChatAttachment?id=...&project_id=..." />`.
…g chat attachments.

The `/rpc/assets.serveChatAttachment` endpoint can be accessed with an API key or session cookie. `Gram-Project` is not used on that endpoint to make it easy for session-based clients to embed attachments in chat such as with `<img>` tags for images e.g. `<img src="/rpc/assets.serveChatAttachment?id=...&project_id=..." />`.
@disintegrator disintegrator enabled auto-merge (squash) January 9, 2026 17:46
@disintegrator disintegrator merged commit bef31df into main Jan 9, 2026
17 checks passed
@disintegrator disintegrator deleted the asset-attachments branch January 9, 2026 17:52
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants