Commit dc6f958
committed
feat: support for image generation (#980)
This PR introduces image generation support to Bifrost and wires it into the existing gateway infrastructure. It adds core schemas, provider extensions, HTTP transport, streaming plumbing, cache integration, and initial UI support to address #950.
Implementation is in progress. Completed functionality is marked, and remaining work will be completed in follow-up commits before marking this PR ready for review.
Scoped Changes:
- [x] New /v1/images/generations endpoint (OpenAI-compatible)
- [x] Image generation via Chat Completion API (tool use pattern)
- [x] Image generation via Responses API (native support)
- [x] Streaming image delivery (base64 chunks)
- [x] Semantic caching for image generation
- [x] UI components for image rendering
- [x] Provider implementations: OpenAI DALL-E, Azure DALL-E
Rollout Plan:
- [x] Phase 1: Core schema and provider implementation (OpenAI + Azure)
- [x] Phase 2: HTTP transport and non-streaming endpoint
- [x] Phase 3: Streaming support and accumulator
- [x] Phase 4: Semantic cache integration (Base64 storage, 5min TTL)
- [x] Phase 5: UI components and documentation
- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [x] Documentation
- [ ] Chore/CI
- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [x] Plugins
- [x] UI (Next.js)
- [x] Docs
Unit Tests
- [x] Schema serialization/deserialization
- [x] Request transformation (Bifrost → OpenAI format)
- [x] Response transformation (OpenAI → Bifrost format)
- [x] Stream chunk accumulation
- [x] Cache key generation
Integration Tests
- [x] End-to-end image generation (non-streaming)
- [x] End-to-end streaming image generation
- [x] Fallback to secondary provider
- [x] Cache hit/miss scenarios
- [x] Error handling (rate limits, invalid prompts)
Load Tests
- [x] Concurrent image generation requests
- [x] Stream memory usage under load
- [x] Cache performance at scale
End-to-end image generation
```sh
curl -X POST http://localhost:8080/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "openai/dall-e-3",
"prompt": "A serene Japanese garden with cherry blossoms",
"size": "1024x1024",
"quality": "high",
"response_format": "b64_json"
}'
```
Expected Outcome:
```json
{
"id": "abc123",
"created": 1699999999,
"model": "dall-e-3",
"data": [
{
"b64_json": "iVBORw0KGgo...",
"revised_prompt": "A tranquil Japanese garden featuring blooming cherry blossom trees...",
"index": 0
}
],
"usage": {
"prompt_tokens": 15,
"total_tokens": 15
},
"extra_fields": {
"provider": "openai",
"latency_ms": 8500,
"cache_debug": null
}
}
```
Unit Tests:
```sh
go test -v github.com/maximhq/bifrost/core/providers/openai -run TestImage
go test -v github.com/maximhq/bifrost/core -run TestImage
```
Expected outcome: PASS
Note: Might need to replace remote paths with local modules in go.mod (Once PR is merged, this directive is not needed)
```sh
replace github.com/maximhq/bifrost/core => ../../core
```
N/A
- [ ] Yes
- [x] No
Closes #950
N/A
- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable1 parent d2ff684 commit dc6f958
File tree
130 files changed
+8338
-487
lines changed- core
- internal/testutil
- providers
- anthropic
- azure
- bedrock
- cerebras
- cohere
- elevenlabs
- gemini
- groq
- huggingface
- mistral
- nebius
- ollama
- openai
- openrouter
- parasail
- perplexity
- sgl
- utils
- vertex
- xai
- schemas
- docs
- openapi
- paths
- inference
- integrations/openai
- schemas
- inference
- integrations/openai
- providers/supported-providers
- quickstart
- gateway
- go-sdk
- framework
- configstore
- tables
- logstore
- modelcatalog
- streaming
- tracing
- plugins
- logging
- maxim
- semanticcache
- tests/integrations/python
- tests
- utils
- transports
- bifrost-http
- handlers
- integrations
- ui
- app/workspace
- logs/views
- providers
- dialogs
- fragments
- components/chat
- lib
- constants
- types
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
130 files changed
+8338
-487
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1005 | 1005 | | |
1006 | 1006 | | |
1007 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
1008 | 1096 | | |
1009 | 1097 | | |
1010 | 1098 | | |
| |||
2320 | 2408 | | |
2321 | 2409 | | |
2322 | 2410 | | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
2323 | 2417 | | |
2324 | 2418 | | |
2325 | 2419 | | |
| |||
2761 | 2855 | | |
2762 | 2856 | | |
2763 | 2857 | | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
2764 | 2861 | | |
2765 | 2862 | | |
2766 | 2863 | | |
| |||
2772 | 2869 | | |
2773 | 2870 | | |
2774 | 2871 | | |
| 2872 | + | |
2775 | 2873 | | |
2776 | 2874 | | |
2777 | 2875 | | |
| |||
3246 | 3344 | | |
3247 | 3345 | | |
3248 | 3346 | | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
3249 | 3353 | | |
3250 | 3354 | | |
3251 | 3355 | | |
| |||
3336 | 3440 | | |
3337 | 3441 | | |
3338 | 3442 | | |
| 3443 | + | |
| 3444 | + | |
3339 | 3445 | | |
3340 | 3446 | | |
3341 | 3447 | | |
| |||
3651 | 3757 | | |
3652 | 3758 | | |
3653 | 3759 | | |
| 3760 | + | |
3654 | 3761 | | |
3655 | 3762 | | |
3656 | 3763 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
250 | 255 | | |
251 | 256 | | |
252 | 257 | | |
253 | | - | |
| 258 | + | |
254 | 259 | | |
255 | 260 | | |
256 | 261 | | |
| |||
669 | 674 | | |
670 | 675 | | |
671 | 676 | | |
| 677 | + | |
672 | 678 | | |
673 | 679 | | |
674 | 680 | | |
| |||
688 | 694 | | |
689 | 695 | | |
690 | 696 | | |
| 697 | + | |
| 698 | + | |
691 | 699 | | |
692 | 700 | | |
693 | 701 | | |
| |||
730 | 738 | | |
731 | 739 | | |
732 | 740 | | |
| 741 | + | |
| 742 | + | |
733 | 743 | | |
734 | 744 | | |
735 | 745 | | |
| |||
764 | 774 | | |
765 | 775 | | |
766 | 776 | | |
| 777 | + | |
| 778 | + | |
767 | 779 | | |
768 | 780 | | |
769 | 781 | | |
| |||
797 | 809 | | |
798 | 810 | | |
799 | 811 | | |
| 812 | + | |
| 813 | + | |
800 | 814 | | |
801 | 815 | | |
802 | 816 | | |
| |||
815 | 829 | | |
816 | 830 | | |
817 | 831 | | |
| 832 | + | |
818 | 833 | | |
819 | 834 | | |
820 | 835 | | |
| |||
833 | 848 | | |
834 | 849 | | |
835 | 850 | | |
| 851 | + | |
| 852 | + | |
836 | 853 | | |
837 | 854 | | |
838 | 855 | | |
| |||
851 | 868 | | |
852 | 869 | | |
853 | 870 | | |
854 | | - | |
855 | | - | |
856 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
857 | 875 | | |
858 | 876 | | |
859 | 877 | | |
| |||
867 | 885 | | |
868 | 886 | | |
869 | 887 | | |
| 888 | + | |
| 889 | + | |
870 | 890 | | |
871 | 891 | | |
872 | 892 | | |
| |||
900 | 920 | | |
901 | 921 | | |
902 | 922 | | |
| 923 | + | |
| 924 | + | |
903 | 925 | | |
904 | 926 | | |
905 | 927 | | |
| |||
928 | 950 | | |
929 | 951 | | |
930 | 952 | | |
| 953 | + | |
| 954 | + | |
931 | 955 | | |
932 | 956 | | |
933 | 957 | | |
| |||
956 | 980 | | |
957 | 981 | | |
958 | 982 | | |
| 983 | + | |
| 984 | + | |
959 | 985 | | |
960 | 986 | | |
961 | 987 | | |
| |||
997 | 1023 | | |
998 | 1024 | | |
999 | 1025 | | |
| 1026 | + | |
1000 | 1027 | | |
1001 | 1028 | | |
1002 | 1029 | | |
| |||
1015 | 1042 | | |
1016 | 1043 | | |
1017 | 1044 | | |
| 1045 | + | |
| 1046 | + | |
1018 | 1047 | | |
1019 | 1048 | | |
1020 | 1049 | | |
| |||
1048 | 1077 | | |
1049 | 1078 | | |
1050 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
1051 | 1082 | | |
1052 | 1083 | | |
1053 | 1084 | | |
| |||
1066 | 1097 | | |
1067 | 1098 | | |
1068 | 1099 | | |
| 1100 | + | |
1069 | 1101 | | |
1070 | 1102 | | |
1071 | 1103 | | |
| |||
1082 | 1114 | | |
1083 | 1115 | | |
1084 | 1116 | | |
| 1117 | + | |
| 1118 | + | |
1085 | 1119 | | |
1086 | 1120 | | |
1087 | 1121 | | |
| |||
1094 | 1128 | | |
1095 | 1129 | | |
1096 | 1130 | | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1100 | 1135 | | |
1101 | 1136 | | |
1102 | 1137 | | |
| |||
1116 | 1151 | | |
1117 | 1152 | | |
1118 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
1119 | 1156 | | |
1120 | 1157 | | |
1121 | 1158 | | |
0 commit comments