@@ -73,6 +73,8 @@ impl OpenRouterConfig {
73
73
. post ( "https://openrouter.ai/api/v1/chat/completions" )
74
74
. header ( "Authorization" , format ! ( "Bearer {}" , api_key) )
75
75
. header ( "Content-Type" , "application/json" )
76
+ . header ( "HTTP_Referer" , "https://dria.co/" )
77
+ . header ( "X-Title" , "dria" )
76
78
. body (
77
79
serde_json:: json!( {
78
80
"model" : model. to_string( ) ,
@@ -115,21 +117,21 @@ mod tests {
115
117
116
118
#[ tokio:: test]
117
119
#[ ignore = "requires OpenRouter API key" ]
118
- async fn test_openai_check ( ) {
120
+ async fn test_openrouter_check ( ) {
119
121
let _ = dotenvy:: dotenv ( ) ; // read api key
120
122
assert ! ( env:: var( ENV_VAR_NAME ) . is_ok( ) , "should have api key" ) ;
121
123
env:: set_var ( "RUST_LOG" , "none,dkn_workflows=debug" ) ;
122
124
let _ = env_logger:: builder ( ) . is_test ( true ) . try_init ( ) ;
123
125
124
- let models = vec ! [ Model :: GPT4Turbo , Model :: GPT4o , Model :: GPT4oMini ] ;
126
+ let models = vec ! [ Model :: ORDeepSeek2_5 , Model :: ORLlama3_1_8B ] ;
125
127
let config = OpenRouterConfig :: new ( ) ;
126
- let res = config. check ( models. clone ( ) ) . await ;
127
- assert_eq ! ( res. unwrap ( ) , models) ;
128
+ let res = config. check ( models. clone ( ) ) . await . unwrap ( ) ;
129
+ assert_eq ! ( res, models) ;
128
130
129
131
env:: set_var ( ENV_VAR_NAME , "i-dont-work" ) ;
130
132
let config = OpenRouterConfig :: new ( ) ;
131
- let res = config. check ( vec ! [ ] ) . await ;
132
- assert ! ( res. is_err ( ) ) ;
133
+ let res = config. check ( vec ! [ ] ) . await . unwrap ( ) ;
134
+ assert ! ( res. is_empty ( ) ) ; // does not return an Err unlike others!
133
135
134
136
env:: remove_var ( ENV_VAR_NAME ) ;
135
137
let config = OpenRouterConfig :: new ( ) ;
0 commit comments